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

select criteria IN statement not in SQL 1

Status
Not open for further replies.

beltmanjr

Technical User
Oct 29, 2007
333
NL
Hi all,

I have a string type parameter called myParam and I manually give it the value '1','2','3','4'

In the select expert I tell it to find the matching records:
{SOME FIELD} in {?myParam}

I know that Crystal will eventually get me the correct results, but when looking at the SQL-query of Crystal it leaves the statement out completely.

When the table is a bit larger this is bad news.

Just in case you wondered why I want to do this:
In my main report I'm putting a string together, comma seperated, with data read from the database.

The subreport needs this data as a select criteria.

I tried to use a local Array stringVar and split the result of the string so I'm passing a real array to the IN statement, but it didn't help.

Hope someone knows how to fix this.
Many thanks
JR
 
Which version of Crystal are you using.

Just as a test if you change select to

{SOME FIELD} in ['1','2','3','4']

Does that get parsed to SQL

Ian
 
Ah, CR v XI R2 and 2008.
The {SOME FIELD} in ['1','2','3','4'] does get passed
 
TRy replacing your parameter with this

@list
join({?myParam}, ",")

Ian
 
what I meant was create thjat formula and in select

{SOME FIELD} in {@list}

or

{SOME FIELD} in [{@list}]

Ian
 
Great stuff!
I am so HAPPY!

You gave me an idea which doesnt make sense but does work. This must be to do with using variables and the crystal passes.

So, I inserted the string parameter in a formula:

@list
Code:
{?myParam)

And the select criteria looks like:
Code:
{SOME FIELD} in split(@list,',')

The parameter has a simple string in it like: '1,2,3,4',
Hence we dont need to join, but do need to split to give the select statement IN an array.
 
YOur solution does make sense. I did not appreciate that your param already had the "," separating string numbers.


Ian
 
I dont get why

{SOME FIELD} in split(?myParam,',')

doesnt work though
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top