If you create a Crystal Report using the built in wizard, tables are linked, etc. What determines whether a parameter makes it into the actual SQL statement? Also, why does it enclose everything in double quotes?
For example:
Here would be my base SQL Statement as generated by CR:
SELECT "poitem"."fpono"
, "pomast"."fcompany"
, "pomast"."fvendno"
, "poitem"."fpartno"
, "poitem"."fitemno"
, "poitem"."frelsno"
, "poitem"."fordqty"
, "poitem"."frcpqty"
, "poitem"."fucostonly"
, "poitem"."flstpdate"
FROM "M2MDATA01"."dbo"."pomast" "pomast"
INNER JOIN "M2MDATA01"."dbo"."poitem" "poitem"
ON "pomast"."fpono" = "poitem"."fpono"
Now, watch what happens when I add the following into the select expert editor:
{poitem.fcategory} = "INV" and
not ({poitem.fmultirls} = "Y" and
{poitem.frelsno} = " 0") and
{poitem.fordqty} > {poitem.frcpqty} and
cdate({poitem.flstpdate}) = {?LastPromDate} and
{poitem.forgpdate} = DateTime (2010, 10, 05, 00, 00, 00) and
{pomast.fstatus} = "OPEN"
I added the forgpdate for comparison since I'm asking for dates two different ways.
Here is the SQL I get:
SELECT "poitem"."fpono"
, "pomast"."fcompany"
, "pomast"."fvendno"
, "poitem"."fpartno"
, "poitem"."fitemno"
, "poitem"."frelsno"
, "poitem"."fordqty"
, "poitem"."frcpqty"
, "poitem"."fucostonly"
, "poitem"."flstpdate"
, "poitem"."fcategory"
, "poitem"."fmultirls"
, "pomast"."fstatus"
, "poitem"."forgpdate"
FROM "M2MDATA01"."dbo"."pomast" "pomast"
INNER JOIN "M2MDATA01"."dbo"."poitem" "poitem"
ON "pomast"."fpono" = "poitem"."fpono"
WHERE "poitem"."fcategory" = 'INV'
AND("poitem"."fmultirls" <> 'Y'
OR "poitem"."frelsno" <> ' 0')
AND "poitem"."fordqty" > "poitem"."frcpqty"
AND("poitem"."forgpdate" >= {TS '2010-10-05 00:00:00'}
AND "poitem"."forgpdate" < {TS '2010-10-05 00:00:01'})
AND "pomast"."fstatus" = 'OPEN'
Most of it is transferred directly, however it converted my "Not" statement.
Also, notice how my cdate line was not sent at all, but is resolved within Crystal itself.
Does anyone know exactly how Crystal decides what to do? I work with some large databases and need my criteria in the SQL statement otherwise Crystal returns huge datasets which waste time, memory, and processing.
TIA.