Subject critique this please
Author Dixon Epperson
still a little unsure of my procedure. I wrote this, (first time
I've used a while do statement) and it seems to work fine. but
would appreciate an expert opinion.

SET TERM !!
DROP PROCEDURE GETINVOICENO!!
COMMIT!!

CREATE PROCEDURE GETINVOICENO
RETURNS (hightn INTEGER) AS
DECLARE VARIABLE pinv VARCHAR(20);
BEGIN
UPDATE LUTABLE SET LU_RATE=LU_RATE + 1 WHERE LU_FIELD='INVNO';

BEGIN
SELECT LU_RATE FROM LUTABLE WHERE LU_FIELD='INVNO' INTO
hightn ;
SELECT SA_INVOICE FROM SALESREG WHERE SA_INVOICE=:hightn
INTO pinv;
WHILE (pinv = hightn) DO
BEGIN
UPDATE LUTABLE SET LU_RATE=LU_RATE + 1 WHERE
LU_FIELD='INVNO';
SELECT LU_RATE FROM LUTABLE WHERE LU_FIELD='INVNO'
INTO hightn;
SELECT SA_INVOICE FROM SALESREG WHERE SA_INVOICE=:hightn
INTO pinv;
END
END
SUSPEND;
END !!
COMMIT!!
SET TERM ;

Dixon