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

Can I use variables in a select statement or only parameters

Status
Not open for further replies.

ballman15

Programmer
Dec 7, 2007
3
US
Dynamic sql?
variables in select statements?
assign the value to a parameter using a formula?


I am looking for a better way to handle wild cards. I have reports that concantenate wild cards to the end of parameter values.

For example:

select * from table where col_name like {?p_parameter}+"%"

I don't want to use the like operator unless the user inputs a wild card... I don't seem to be able to dynamically build my parameter values and I can't figure out how to use a variable in the select either. What is the best way to handle wild cards with Crystal? In oracle reports I can use lexical variables or build the entire select statement dynamically. The only way I have found to do this with crystal is to build a stored procedure and build the sql in the procedure. But I have a bunch of reports that need to be tunned that concat the "%" to end of the where clause.

any help would be greatly appreciated.
 
by the way, I am trying to not use the select formulas because I want to filter the data on the database server and not on the client.

I can't seem to get the syntax correct for forcing the where clause down to the database server. So any help there would also be appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top