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!

Switch Not Passing to SQL

Status
Not open for further replies.

Sacheveral

Technical User
Jan 24, 2005
23
GB
Running CR10 in Win XP. According to the help you can pass conditional record selection to the SQL statement in Crystal by using the Switch command. However I have tried the following and it does not seem to work:

{Employee_Man.Descriptor} = "John Smith" or
switch(isnull({Employee_VT.Descriptor}),false,true,{Employee_VT.Descriptor} = "John Smith")

The reason for wanting to do this is that there is always a {Employee_Man.Descriptor}, but only sometimes a {Employee_VT.Descriptor}. If I do it without the switch statement then if {Employee_VT.Descriptor} is null it skips the record, even if it meets the first part of the criteria.

The switch statement works, but does the filtering locally rather than at the server. Can anyone help, and also provide some examples of how to form SQL friendly switch statements generally?

Many thanks,

Joe
 
I would try switching the selection around i.e.

Code:
(isnull({Employee_VT.Descriptor}) or {Employee_VT.Descriptor} = "John Smith") or
{Employee_Man.Descriptor} = "John Smith"

HTH



Gary Parker
MIS Data Analyst
Manchester, England
 
Thanks, but wouldn't that return the record if{Employee_VT.Descriptor} was null, regardless of whether {Employee_Man.Descriptor} matched the name?

Even if there is an alternate solution for this problem, I would be interested to know how to do a switch anyway, and the sort of SQL statement that it produces.

Many thanks,

Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top