Tips and Tricks
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Tips and Tricks
Message Icon Topic: Call a stored procedure in crystal report Post Reply Post New Topic
Author Message
Frankn
Newbie
Newbie
Avatar

Joined: 18 Sep 2012
Online Status: Offline
Posts: 4
Quote Frankn Replybullet Topic: Call a stored procedure in crystal report
    Posted: 20 Nov 2012 at 9:04am
Hi,
I have a stored procedure which I need to pass a parameter from CR but when I call it by
{call "datatest"."dbo"."ZZ_SPECCHANGE";1('''dbo.zzxdzgnh.design_num''')}

it gives me error: "incorrect syntax near the keyword exec"

USE Datatest
GO
CREATE PROCEDURE DBO.ZZ_SPECCHANGE
@idesign_num varchar(30))
RETURNS varchar(75)
AS
BEGIN
DECLARE @FR NUMERIC(8, 2)
DECLARE @WB NUMERIC(8, 2)
DECLARE @FR_WB NUMERIC(8, 2)
DECLARE @output VARCHAR(75)
...

select @FR=(CASE d.SAMPLE_BK
               WHEN 1 THEN d.SIZE01
               WHEN 2 THEN d.SIZE02
               WHEN 3 THEN d.SIZE03
...
               WHEN 23 THEN d.SIZE23
               ELSE d.SIZE24 END)
FROM zzxdzpom d join zzxdzgnh h
on d.DZHDRFKEY = h.pkey and h.design_num = @idesign_num and d.pom_code like 'FRTR%'
if @FR is null set @FR = '0'

select @WB=(CASE d.SAMPLE_BK
               WHEN 1 THEN d.SIZE01
               WHEN 2 THEN d.SIZE02
               WHEN 3 THEN d.SIZE03
...
               WHEN 23 THEN d.SIZE23
               ELSE d.SIZE24 END)
FROM zzxdzpom d join zzxdzgnh h
on d.DZHDRFKEY = h.pkey and h.design_num = @idesign_num and d.pom_code like 'WAIST%'
if @WB is null set @WB = '0'

SET @FR_WB = @FR + @WB
SET @wholenumber = CAST(@FR_WB AS INT)
SET @decimal = @FR_WB - @wholenumber
SET @multiple =
[covert decimal to fraction.....]
ELSE
BEGIN
        SET @output = convert(varchar(75),@wholenumber)
END

RETURN (@output);
END

and also I could not insert this formula on SQL Expression, Any help or suggestion please?

Thanks

Edited by Frankn - 20 Nov 2012 at 10:28am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 21 Nov 2012 at 3:19am
I have never tried to manipulate the call in CR.  I tell CR that I want to use a stored proc, it then prompts me for parameters, and then it sets up the call...all I need to do is change the text for the parameter screen....
so I'm confused as to what you are asking CR to do...
why are tell CR to pass something to it...since what you are passing is not a parameter (it doesn't vary, and there is no user input), why not just have the sp grab the value you want and remove the parameter?
 
 
IP IP Logged
Frankn
Newbie
Newbie
Avatar

Joined: 18 Sep 2012
Online Status: Offline
Posts: 4
Quote Frankn Replybullet Posted: 27 Nov 2012 at 5:42am
Thanks for reply, in fact what I need to do is:
Extracting a size within a table base on contents of a field for example on field sample_size I will read size 23, than on column 23 I will read the content which is decimal(2.5), I need to convert that number to fraction
(2 1/2) and then populate it on my crystal report, what would be the best solution to do this?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 27 Nov 2012 at 7:28am
in all honesty, I don't know.
 
you are just displaying the value 2 1/2, as opposed to setting a control to that size, right?
 
as a rule of thumb, I try to do as much as possible in the stored proc, since it gives much more power and versatility than CR.
IP IP Logged
Frankn
Newbie
Newbie
Avatar

Joined: 18 Sep 2012
Online Status: Offline
Posts: 4
Quote Frankn Replybullet Posted: 27 Nov 2012 at 7:49am
Yes I need to populate value 2 1/2 on CR, on the first post I've made the SP and it works fine on SSRS but my problem is how to call it on CR, on CR I have design_num and base on design numbers I should show what are the sizes(ex. 2 1/2), I've just confused how to pass design_num to SP and return Size to CR.

regards


Edited by Frankn - 27 Nov 2012 at 7:52am
IP IP Logged
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.