Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Crystal Reports - Select Expert Question Post Reply Post New Topic
Author Message
irfan
Newbie
Newbie


Joined: 27 May 2009
Location: Canada
Online Status: Offline
Posts: 16
Quote irfan Replybullet Topic: Crystal Reports - Select Expert Question
     Posted: 27 May 2009 at 10:41am
Hello,
  I am trying to use Etype in my report using the select expert. I want the values that I select in Etype to be substituted in the main query of the report, In oracle we use something like select * from emp where depcode in('10','20','30'). How can we do the same thing in Crystal Reports.
  Basically I want the values that I submit using my select expert to be submitted to the main query as well.
 I tried using something like select * from emp where depcode in {?Etype}
but it does not work. Please advise
 
Thanks
fm
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 28 May 2009 at 1:51am
Hi
what type of parameter is {?Etype}, have you selected the option to accept Allow multiple values to True?
 
Also try replacing the  in keyword with LIKE
cheers
Rahul
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 28 May 2009 at 6:58am
I'll be honest, I don't like arrays much, not in Crystal.  If you can't find an answer for the select statement...I would remove the condition and place it report/selection formula/record.  It would be best to filter it out in the selection though.
 
 
IP IP Logged
irfan
Newbie
Newbie


Joined: 27 May 2009
Location: Canada
Online Status: Offline
Posts: 16
Quote irfan Replybullet Posted: 29 May 2009 at 9:20am
Like operator does not seem to help, as I basically need a concatenation of all the values that get passed from the select expert. For example if the user selects dept 10,20,30 ,then all should get subsitututed in the main query as we do in Oracle using in(10,20,30).
   I also did not understand how we can use a formula column here as we will have to do the same thing which we are unable to do in the main select of the query. Please advise.
Thanks
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 29 May 2009 at 11:04am
OK, you will have some work to do.  You can't pass 10,20,30 to a stored proc and use it in an 'IN' statement.  It gets translated to 'IN ('10,20,30') which is not what you want.
 
For something like that, and I don't know the Oracle syntax, you would want something like CHARINDEX('10,20,30', CONVERT(VARCHAR, fieldName)) > 0
 
though, to get rid of false positives, you would want to surround all with commas an make sure that there are no spaces, then you can use syntax like CHARINDEX(',10,20,30,', ',' + CONVERT(VARCHAR, fieldName) + ',') > 0
 
Crystal is probably doing the same thing.  The way I got around this for my stored procs is to use a function that parses the string 10,20,30 into a table that has the values for the rows.
 
 
with all of this in mind, select * from emp where depcode in {?Etype}  shouldn't work.  Try:
select * from emp where charindex({?Etype}, depcode) > 0 
 
since there could be some false positives, I would follow up with code in the Report/Selection Formulas/Records since you can manipulate the values of {?Etype} or split it into an array and check it that way... 
IP IP Logged
irfan
Newbie
Newbie


Joined: 27 May 2009
Location: Canada
Online Status: Offline
Posts: 16
Quote irfan Replybullet Posted: 29 May 2009 at 11:08am
Thanks a lot I will save this thread, the last post specially is a useful one.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum