Subject | Re: [firebird-support] I'm really new to storedProc and need a little help |
---|---|
Author | Milan Babuskov |
Post date | 2003-08-25T19:03:07Z |
Milan Babuskov wrote:
And now I see it's all wrong. Here's the corrected version:
SET TERM !! ;
CREATE PROCEDURE GETPAYNUM RETURNS (hightn INTEGER) AS
BEGIN
SELECT LU_RATE FROM LUTABLE WHERE LU_FIELD='PYNUM' INTO :hightn;
IF (hightn IS NULL) THEN
BEGIN
INSERT INTO LUTABLE (LU_DESC,LU_FIELD,LU_RATE,LU_ORDER,LU_DEF)
VALUES ('PayNumber', 'PYNUM', 1, 0, 'N');
hightn = 1;
END
ELSE
BEGIN
UPDATE LUTABLE SET LU_RATE=LU_RATE +1 WHERE LU_FIELD='PYNUM';
hightn = hightn + 1;
END
SUSPEND;
END!!
SET TERM ; !!
Enjoy.
--
Milan Babuskov
http://fbexport.sourceforge.net
And now I see it's all wrong. Here's the corrected version:
SET TERM !! ;
CREATE PROCEDURE GETPAYNUM RETURNS (hightn INTEGER) AS
BEGIN
SELECT LU_RATE FROM LUTABLE WHERE LU_FIELD='PYNUM' INTO :hightn;
IF (hightn IS NULL) THEN
BEGIN
INSERT INTO LUTABLE (LU_DESC,LU_FIELD,LU_RATE,LU_ORDER,LU_DEF)
VALUES ('PayNumber', 'PYNUM', 1, 0, 'N');
hightn = 1;
END
ELSE
BEGIN
UPDATE LUTABLE SET LU_RATE=LU_RATE +1 WHERE LU_FIELD='PYNUM';
hightn = hightn + 1;
END
SUSPEND;
END!!
SET TERM ; !!
Enjoy.
--
Milan Babuskov
http://fbexport.sourceforge.net