Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula in SQL Post Reply Post New Topic
Author Message
newsomer
Newbie
Newbie
Avatar

Joined: 09 Mar 2009
Online Status: Offline
Posts: 4
Quote newsomer Replybullet Topic: Formula in SQL
     Posted: 09 Mar 2009 at 12:30pm
Can CR formulas be used in the SQL for database queries or are we limited to parameters alone?

I need to create a parameter that a user can select to indicate they want to see current or previous quarter data.

For lack of a better way I have created a parameter with values of 0 for current and -1 for previous quarter. The parameter is passed to one of two formulas that call a function providing either the start date or end date of the requested quarter. I have placed the formula name in braces in the SQL but I am guessing the formula isn't evaluated early enough to work in the SQL query.

If this is the case how then can you create a parameter that will provide the start and end dates for the requested quarter? Are we left with just expecting the user to manually enter or select the dates?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 11 Mar 2009 at 7:41am

If the only values are either the current quarter or the prior, I would create Command (Database Expert) that would return the verbiage you desire and the dates that match.  You can then pass these to the report.

If you are getting the data from a stored proc, just pass the 0 or -1 and have the database/stored proc figure out what the date range is.
 
If you are connecting to the data base, then you could use your functions in the filter section of the report (Report/Selection Formulas/Record).  Don't worry about how to format the names, just double click on them from the pane above.
 
Hope one of these options works for you.
IP IP Logged
newsomer
Newbie
Newbie
Avatar

Joined: 09 Mar 2009
Online Status: Offline
Posts: 4
Quote newsomer Replybullet Posted: 26 Mar 2009 at 7:22am
Thank you for your response. The problem is that I need to pass the parameter to the Oracle database to perform record filtering. If I didn't it would take forever for the report to perform filtering. The parameter value prompt for the command is real weak but I guess we'll just have to live with it.

Thanks again and apologies for not getting back to this sooner.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 26 Mar 2009 at 1:18pm
Another option would be to create a stored function that would take the parameter value and return the correct dates.  You may need two - one for the start date and one for the end date.  You would then use that function in your SQL command.
 
-Dell
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum