Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Parameters to the SQL Query

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi

Is there a way to pass the report parameters to an SQL query within a Crystal Report? I need to be able to perform this feature because the recordset that is returned from the server to the report contains too many records, which get suppressed by the selection formula one by one. This greatly slows down the report.

Here is what I mean by passing the parameters to the SQL query. Lets say that I have the following selection formula
{_TELMASTE_.DATE OPEN}>={?FromDate} and
{_TELMASTE_.DATE OPEN} <={?ToDate}

and the following SQL query (the two are not in sync with each other)
SELECT
ATELMASTE_.&quot;Sequence&quot;, ATELMASTE_.&quot;Note&quot;, ATELMASTE_.&quot;DATE OPEN&quot;, ATELMASTE_.&quot;CLOSED ON&quot;, ATELMASTE_.&quot;DESCRIPTION&quot;, ATELMASTE_.&quot;RESOLUTION&quot;,
ACUSTOMER_.&quot;FNAME&quot;, ACUSTOMER_.&quot;NAME&quot;,
ASUBJECTS_.&quot;DESCRIPTION&quot;
FROM
&quot;_SMDBA_&quot;.&quot;_TELMASTE_&quot; ATELMASTE_, &quot;_SMDBA_&quot;.&quot;_SUBJECTS_&quot; ASUBJECTS_ , &quot;_SMDBA_&quot;.&quot;_CUSTOMER_&quot; ACUSTOMER_
WHERE
ATELMASTE_.&quot;SUBJECT&quot; = ASUBJECTS_.&quot;Sequence&quot; AND ATELMASTE_.&quot;Client&quot; = ACUSTOMER_.&quot;Sequence&quot; AND ASUBJECTS_.&quot;DESCRIPTION&quot; not like 'MSR%'
ORDER BY
ASUBJECTS_.&quot;DESCRIPTION&quot; ASC,
ATELMASTE_.&quot;Sequence&quot; ASC

Is there a way to pass the {?FromDate} and the {?ToDate} parameter values to the SQL query?

Any help regarding this issues is appreciated.

Thank you in advance

Eugene Kravchenko
 
You can create Parameters for your SQL Query (in Crystal SQL DEsigner).

JUst make sure you are viewing the result set within SQL Designer. In that mode, use the menu option of Edit,
Parameter Field...

Cheers,
- Ido ixm7@psu.edu
 
I've noticed that if you create the report using the report expert(wizard) the parameters can be passed to the query. I'm pointing this out because the report will be used in a web based reporting system. And using the SQL Designer will force me to incorporate an SQL Designer file with the actual report. That is there a way to do it within Crystal Reports itself? Because it does seem to support this functionality as I've noticed from the Report Expert(Wizard).

Thank you in advance
 
You can append a WHERE clause to the existing one programmatically.

Cheers,
- Ido ixm7@psu.edu
 
Include field _TELMASTE_.DATE OPEN in the SQL Select statement.
In CR Select Expert:
set the value in the first drop down box to &quot;is between&quot;
set the vakue in the second drop down box to &quot;?FromDate&quot;
set the value in the third drop down box to &quot;?ToDate&quot;

When you click &quot;OK&quot; the parameters will be added to you r WHERE clause
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top