Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8581

Re: How to link a table using a command

$
0
0

Hi Dave,

 

The slowness in the report is due to the fact that you're combining a command with tables.  Crystal will pull all of the data into memory and then do the join there in this situation, which can significantly slow down a report.

 

I would modify the report to use a single command without any tables.  That command might look something like this:

 

SELECT

   PRLREGLIN.COMP_NO,

   PRLREGLIN.REG_REF,

   PRLREGLIN.VAT_EXCLUSIVE,

   PRLREGLIN.GL_CODE,

   IsNull(PRLREGLIN.GL_CODE, 'TEST') as GLCODE,

   Reputils.f_numbertodate(PRLREGHED.DATE_SETUP),

   RSSGLGRNORD.GL_CODE,

   Case IsNull(PRLREGLIN.TY_PE, 'N/A')

     when 'CRN' THEN 0-PRLREGLIN.VAT_EXCLUSIVE

     else PRLREGLIN.VAT_EXCLUSIVE

   end VATEXCL,

   whosetup.FULLNAME as SETUP_USER,

   RSSCENSUP.SUPP_NAME

FROM  PRLREGLIN

   LEFT JOIN PRLREGHED

     ON PRLREGLIN.COMP_NO=PRLREGHED.COMP

     AND PRLREGLIN.REG_REF=PRLREGHED.REF)

   Left Join RSSGLGRNORD

     PRLREGLIN.GRN_LINE = RSSGLGRNORD.GRN_NO + RSSGLGRNORD.GRN_LINE_NO

   Left Join RSSCENSUP

     on PRLREGHED.SUPPLIER = RSSCENSUP.SUPPLIER

   Left Join SYSINTUSERS as whosetup

     on PRLREGHED.WHO_SETUP = whosetup.USERNAME

WHERE PRLREGLIN.REG_REF>='0010000003'

   AND PRLREGLIN.REG_REF<='0010000064'

ORDER BY PRLREGLIN.COMP_NO, PRLREGLIN.REG_REF

 

To get this, I went to "Show SQL Query" on the database menu and got the main query for the report which I simplified - Crystal adds a bunch of syntax stuff to the query that's not really needed and which, IMHO, makes it more difficult to read.  I then added in the table from the command and the other two tables from the Database Expert which weren't used under "Show SQL Query" because none of the fields from them were in the report.  The last thing that I did was convert both of your formulas to SQL so that the command will bring back the values you're looking for from the database instead of having Crystal do the calculation.

 

If you need additional fields on the report, you'll add them to the command so that they're available in the report.  DO NOT add tables to the report - you'll do it ALL in the command.  Once you have the command set up, delete the tables from the Database Expert.

 

I also see that you have three parameters in the report that are not being used anywhere.  The correct way to use this will be in the Where clause of the command, NOT in the Select Expert.  However, the Command Editor will not be able to "see" the parameters that you've configured in the report.  So, here's what I recommend that you do:

 

1.  Open the Company Codes param, click on the "Actions" drop-down and export the list of values that you've added for it.  This way you won't have to re-type them when you recreate the parameter.

 

2.  Delete all three parameters.

 

3.  Open the Command Editor (in the Database Expert, right-click on the command and edit it.)

 

4.  Create the parameters in the Command Editor - you won't be able to add the list of values here, but we'll get to that in the next step.  In order for the parameters to actually be saved, they have to be used in the command.  Also, you'll have to create two parameters for the Payment Dates - the command won't let you create a range parameter, so you'll have something like "Payment Date Start" and "Payment Date End" and you'll use them like this in the Where clause:

 

table.DateField >= {?Payment Date Start} and table.DateField <= {?Payment Date End}

 

Save the command when you're done.  You could even add one parameter at a time, save the command and test it just to make sure that you're getting the results you expect.

 

5.  The parameters you added will now appear in the Parameter Fields section of the Field Explorer.  Edit the Company Codes parameter to import the list of data that was exported in step 1 above.

 

Please let me know if you have any questions.

 

-Dell


Viewing all articles
Browse latest Browse all 8581

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>