Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Error in case statement Post Reply Post New Topic
Author Message
Evil McBad
Newbie
Newbie
Avatar

Joined: 06 Feb 2008
Location: United Kingdom
Online Status: Offline
Posts: 10
Quote Evil McBad Replybullet Topic: Error in case statement
     Posted: 23 Dec 2009 at 4:23am
I have a report based on a command, where I need to create a parameter which allows a user to enter a month and the report will then use the corresponding period number.
 
I have added a case statement to the where clause as follows:
 
WHERE `Results`.`Period` =
CASE {?Month}
where 'Apr' then 1
Where 'May' then 2
where 'Jun' then 3
where 'Jul' then 4
where 'Aug' then 5
Where 'Sep' then 6
where 'Oct' then 7
where 'Nov' then 8
where 'Dec' then 9
where 'Jan' then 10
where 'Feb' then 11
else 12
END
BUT - I keep getting the error "Syntax error (missing operator) in query expression"
 
I have no idea why - can anyone help???
Evil
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 23 Dec 2009 at 6:34am
SQL Server's Case statement is CASE xxx WHEN ...
 
I don't know how many times I've made that same mistake...
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 23 Dec 2009 at 7:51am
Can you pass a crystal parameter to a Command?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 24 Dec 2009 at 6:26am
I've read other posts here where they have.  As I recall, the other posts had issues with parameters appearing twice...I think, once for the parameter and once for the command.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 24 Dec 2009 at 6:50am
Thanks lockwelle... Could have sworn Commands would not pass the params the way a stored proc would and the double params were still in stored procs where they added the params in both the sp and crystal too.
 
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