Subject | Re: [firebird-support] Access to Stored Procedure |
---|---|
Author | Helen Borrie |
Post date | 2004-03-22T12:05:27Z |
At 04:26 AM 22/03/2004 -0600, you wrote:
Get rid of the double quotes, or use them consistently. But there is no
possible reason to use them in made-up data, anyway.
CREATE PROCEDURE TESTPROC
RETURNS
(
ID CHAR(30) CHARACTER SET WIN1252
)
AS
/* casting should not be integer */
DECLARE VARIABLE xpart VARCHAR(11); /* 30 is too much for 32-bit int */
DECLARE VARIABLE NewNum INTEGER;
BEGIN
NewNum = GEN_ID(CCPART_GEN,1);
/* xPart = Cast(Newnum as INTEGER); */
xPart = cast(NewNum as varchar(11);
WHILE (STRLEN(xPart)<6) DO
BEGIN
xPart = ('0'||xPart);
END
ID= ('CCS-'||Xpart);
EXIT;
END
>HiSELECT "ID" FROM TESTPROC would do it.
>I have created a stored procedure
>CREATE PROCEDURE "TESTPROC"
>RETURNS
>(
> "ID" CHAR(30) CHARACTER SET WIN1252
>)
>AS
>DECLARE VARIABLE xpart VARCHAR(30);
>DECLARE VARIABLE NewNum INTEGER;
>BEGIN
> NewNum = GEN_ID(CCPART_GEN,1);
> xPart = Cast(Newnum as INTEGER);
> WHILE (STRLEN(xPart)<6) DO
> BEGIN
> xPart = ('0'||xPart);
> END
> ID= ('CCS-'||Xpart);
>EXIT;
>END
>
>My query is how do access this from my application or IbConsole
>
>Using
>
>SELECT ID FROM TESTPROC
>
>activates the procedure and increments the generator but I get null as a
>result.
Get rid of the double quotes, or use them consistently. But there is no
possible reason to use them in made-up data, anyway.
CREATE PROCEDURE TESTPROC
RETURNS
(
ID CHAR(30) CHARACTER SET WIN1252
)
AS
/* casting should not be integer */
DECLARE VARIABLE xpart VARCHAR(11); /* 30 is too much for 32-bit int */
DECLARE VARIABLE NewNum INTEGER;
BEGIN
NewNum = GEN_ID(CCPART_GEN,1);
/* xPart = Cast(Newnum as INTEGER); */
xPart = cast(NewNum as varchar(11);
WHILE (STRLEN(xPart)<6) DO
BEGIN
xPart = ('0'||xPart);
END
ID= ('CCS-'||Xpart);
EXIT;
END