Subject I'm really new to storedProc and need a little help
Author dixonepperson
Ive written the following to get a number, but if the row in the
lookup table hasn't been created yet, I want to create a new record
and return a default value of 1.

SET TERM !!
CREATE PROCEDURE GETPAYNUM RETURNS (hightn INTEGER) AS
BEGIN
UPDATE LUTABLE SET LU_RATE=LU_RATE +1 WHERE LU_FIELD='PYNUM';
FOR SELECT LU_RATE FROM LUTABLE WHERE LU_FIELD='PYNUM' INTO hightn
DO
IF (LU_RATE IS NULL) THEN
BEGIN
INSERT INTO LUTABLE (LU_DESC, LU_FIELD, LU_RATE, LU_ORDER,
LU_DEF)
VALUES ('PayNumber', 'PYNUM', 1, 0, 'N');

SELECT LU_RATE FROM LUTABLE WHERE LU_FIELD='PYNUM' INTO
hightn;
END
SUSPEND;
END!!
SET TERM ;

Dixon