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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement based off of Parameter 2

Status
Not open for further replies.

snazzyCrunch

Technical User
Apr 18, 2002
26
0
0
US

I have a fairly simple question about setting the SQL select statement based of a parameter value.

These are my two cases:

1. {?REQCustomer} = "ALL" then I would like to execute the follwing SQL stmt...

Code:
Select * from DB where fieldName like '%string%'[\code]

2. {?REQCustomer} = "Specified String"

[code]Select * from DB where fieldName = 'Specified String'

I am using CR8.5. Any help is appreciated.
Thanks in advance,
bobbyf24@yahoo.com
 
If I understand you correctly you want to:

1. Prompt the user for a string
2. If they enter 'ALL', you want to apply a default query
3. If they enter something else, you want to use that in your query.

If this is the case, you need to set the selection formula to something like:

if {?REQCustomer} = "ALL" then
DB.fieldName like '%string%'
else
DB.fieldName = {?REQCustomer}

Crystal is quite happy for you to have IF statements in the selection criteria. Hope this helps.
Steve Phillips, Crystal Consultant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top