Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Urgent: Select query in Crystal Report Post Reply Post New Topic
Page  of 2 Next >>
Author Message
bujji
Newbie
Newbie
Avatar

Joined: 17 Dec 2008
Location: India
Online Status: Offline
Posts: 6
Quote bujji Replybullet Topic: Urgent: Select query in Crystal Report
    Posted: 18 Dec 2008 at 12:02am
Hi,
 
I have a prompt which takes the user input as 'OPN' ,'TND','*'.
According to his input i should execute one select query if it is 'OPN'
and if he selects 'TND' i should execute one more select query ...
How can i implement this in Crystal Report 11.0 version?
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: 18 Dec 2008 at 12:19am
Hi,
 
How is the prompt set ,does it take multiple values or single value......
 
In your record selection formula you can check for
 
{table.fieldname} like {?prompt_name}
 
Cheers
Rahul
IP IP Logged
bujji
Newbie
Newbie
Avatar

Joined: 17 Dec 2008
Location: India
Online Status: Offline
Posts: 6
Quote bujji Replybullet Posted: 18 Dec 2008 at 12:24am
I have a drop-down so the user has to select only one value either 'TND' or 'OPN' or '*'.
 
but how can i mention the select query in this selection formula ?
 
i wrote somethign like this but am getting error :
 
(if uppercase ({Command.STATUS}) = 'OP'
 then
select distinct ld_leg_id,Status from ld_lge_t where CUR_OPTLSTAT_ID in (300)
else
(if uppercase({Command.STATUS} = 'TND' then
select distinct ld_leg_id,Status from ld_lge_t where CUR_OPTLSTAT_ID in (320)
else
Select DISTINCT ld_leg_id, 'OPN' AS status from LD_LEG_T where CUR_OPTLSTAT_ID =300
UNION
Select DISTINCT ld_leg_id, 'TND' AS status from LD_LEG_T where CUR_OPTLSTAT_ID =320
))
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: 18 Dec 2008 at 12:30am

Hi

I am not clear what you looking for in the report,Have you used command object ?,can't it be done  using tables ,or views......
 
Please let me know what is the expected output in your report ,also if you could post some sample data ......
 
Cheers
Rahul
IP IP Logged
bujji
Newbie
Newbie
Avatar

Joined: 17 Dec 2008
Location: India
Online Status: Offline
Posts: 6
Quote bujji Replybullet Posted: 18 Dec 2008 at 12:38am
Hi,
 
I have one prompt in the report as 'Status' which has the option of drop-down and it has values 'OPN' and 'TND' and '*'
 
if the user selects 'OPN' i have to display all the loads which have the value as 300 for the column CUR_OPTLSTAT_ID in the table 'ld_leg_t '.
the select query for this will be "select distinct ld_leg_id,Status from ld_lge_t where CUR_OPTLSTAT_ID in (300)"
 
similarly for 'TND' i have to display all the loads which have the value as 320 for the column CUR_OPTLSTAT_ID in the table 'ld_leg_t '.the select query for this will be "select distinct ld_leg_id,Status from ld_leg_t where CUR_OPTLSTAT_ID in (320)"
 
similarly for '*' i have to display all the loads which have the value as 320,300 for the column CUR_OPTLSTAT_ID in the table 'ld_leg_t '.the select query for this will be "select distinct ld_leg_id,Status from ld_leg_t where CUR_OPTLSTAT_ID in (320,300)"
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: 18 Dec 2008 at 12:56am
Hi
 
Have you created command object and coded IF else in it ,if yes remove the if else part.
 
Open your report, go to record selection formula , then use the code below
 
 if {?My Parameter} = 'OPN' then CUR_OPTLSTAT_ID  in (300)
ELSE
IF
{?My Parameter} = 'TND' then CUR_OPTLSTAT_ID  in (320)
else
{CUR_OPTLSTAT_ID}  Like {?My Parameter}
 
Cheers
Rahul
 
IP IP Logged
bujji
Newbie
Newbie
Avatar

Joined: 17 Dec 2008
Location: India
Online Status: Offline
Posts: 6
Quote bujji Replybullet Posted: 18 Dec 2008 at 1:19am
Hi i tried ur way,
 
but when am trying to save it it's displaying "A number range is required here" for (300).
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: 18 Dec 2008 at 1:25am
Hi
Sorry my mistake try this
 
if {?My Parameter} = 'OPN' then CUR_OPTLSTAT_ID  in [300]
ELSE
IF
{?My Parameter} = 'TND' then CUR_OPTLSTAT_ID  in [320]
else
{CUR_OPTLSTAT_ID}  Like {?My Parameter}
 
 
 
Does the query work with *  parameter value 
 
Cheers
Rahul


Edited by rahulwalawalkar - 18 Dec 2008 at 1:26am
IP IP Logged
bujji
Newbie
Newbie
Avatar

Joined: 17 Dec 2008
Location: India
Online Status: Offline
Posts: 6
Quote bujji Replybullet Posted: 18 Dec 2008 at 3:12am
Hi,
 
I'm not able to fetch any records for any value Cry
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: 18 Dec 2008 at 3:39am

Hi

 
email me your report and some sample data in xls sheet
 
 
cheers
rahul
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.