|
-
Jul 19th, 2008, 03:49 PM
#1
Thread Starter
Member
passing Parameter to QUERY?
Hi
Im trying to pass a user entered parameter to the WHERE clause of my SQL QUERY statement, can someone tell me how to do this?
For example, instead of the date entered below , I wish for "'20071010'" to be a user prompted value. How would I do this?
SELECT
SALES_HISTORY_DETAIL."SHD_DESCRIPTION",
FROM
SALES_HISTORY_DETAIL
WHERE
SALES_HISTORY_DETAIL.INVOICE_DATE = "20071010"
Thanks!
-
Jul 21st, 2008, 06:44 AM
#2
Frenzied Member
Re: passing Parameter to QUERY?
umm you're going to have to tell use what you're using for your reporting and what you would like to pass your variable from...
-
Jul 21st, 2008, 10:52 AM
#3
Thread Starter
Member
Re: passing Parameter to QUERY?
hi
Im using CR 8.5
Im trying to pass user prompted parameters to the SQL query somehow but Im not having any luck
What Im doing so far is:
1)Creating a Parameter Field called 2)Using the Select Expert to specify which column is to equal the user entered paramater
Code:
{SALES_HISTORY_DETAIL.INVOICE_DATE} = {?userdate}
so far this isnt working for me.
THANKS FOR ANY HELP!
-
Jul 21st, 2008, 11:23 AM
#4
Re: passing Parameter to QUERY?
so far this isnt working for me.
Can you be more specific?
Is the parameter defined as Date or DateTime or ?
Is the Invoice_Date field defined as Datetime or a string?
Verify the SQL statement that CR is using, Database menu -> Show SQL Query.
-
Jul 21st, 2008, 11:45 AM
#5
Thread Starter
Member
Re: passing Parameter to QUERY?
Hi Bruce.
the parameter "userdate" is a string as is the INVOICE_DATE field in the DB so they both match....
Bruce I must ask because I dont know. Once I do a Select Expert entry, will this show up in the SHOW SQL QUERY window? so for example if my SELECT EXPERT entry is
{SALES_HISTORY_DETAIL.INVOICE_DATE} = {?userdate}
will there be anything to this effect in the SQL QUERY?
Because when I do anything to the SELECT EXPERT nothing shows up in the SQL QUERY WINDOW (except what I had initially)
Or does CR first execute the SQL QUERY and THEN it executes the SELECT EXPERT entry?
Thank You
-
Jul 21st, 2008, 03:25 PM
#6
Re: passing Parameter to QUERY?
It depends on whether or not the option "Use Index or Server for speed". If that option is on, then Crystal will generate a Where clause (if it can) from your selection formula.
I always have the option "Perform Grouping on Server" on and the option "Always Sort Locally" off as well.
-
Jul 21st, 2008, 03:58 PM
#7
Thread Starter
Member
Re: passing Parameter to QUERY?
BRUCE, can I put in the SQL QUERY window a where clause that accepts a parameter my self?
-
Jul 21st, 2008, 04:09 PM
#8
Re: passing Parameter to QUERY?
No. The SQL Query window shows you the generated sql statement that is going to be sent to the database server. You can modify the Where clause with hardcoded values but not parameterized values.
-
Jul 21st, 2008, 04:12 PM
#9
Thread Starter
Member
Re: passing Parameter to QUERY?
this is so weird, when I hard code the WHERE CLAUSE my self by putting the date in the SQL QUERY window
Code:
WHERE
SALES_HISTORY_DETAIL.INVOICE_DATE = '20071010'
everything works fine, the minute I take that WHERE CLAUSE out and try to do it with the user parameter it crashes the CR app....
-
Jul 21st, 2008, 04:35 PM
#10
Thread Starter
Member
Re: passing Parameter to QUERY?
BRUCE,
If you don't mind, can you tell me if I'm doing the right steps in creating a user parameter?
1) I take OUT my hard coded WHERE statement from the SQL QUERY window
SALES_HISTORY_DETAIL.INVOICE_DATE = '20071010'
2) I create a user parameter called "userdata" which is just a string
3) I go to the SELECT EXPERT and select the INVOICE_DATE column and use the formula expert to create the following formula:
{SALES_HISTORY_DETAIL.INVOICE_DATE} = {?userdate}
I try to run this report, i enter the user prompted parameter 20071010 and it just hangs......
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|