<<
The temp table workaround is just fine.  Thanks
for scratching your head.
>>


Here's a zero-programming solution (well, except for this stored procedure).  
Save the following code into SEQUENCENO.PRC:

-- PUT SequenceNo.PRC AS SequenceNo RETURN INTEGER

SET VAR pSNo_Int INT -- Do not initialize
IF pSNo_Int IS NULL THEN
  SET VAR pSNo_Int = 1
ELSE
  SET VAR pSNo_Int = (.pSNo_Int + 1)
ENDIF

RETURN (.pSNo_Int)

Then, issue that PUT command in your database.  You now have sequencing 
installed.

Now, whereever you want a sequence number include the expression (CALL 
SequenceNo()).  For instance:

SELECT (CALL SequenceNo()) AS Seq_No, * FROM Employee ORDER BY EmpLastName, 
EmpFirstName

and you'll see that the first number is a sequence number.

Whenever you want your numbering to start over again, simple CLEAR VAR pSNo_Int 
or set it to NULL.
--
Larry

Reply via email to