Subject RE: [ib-support] SET GENERATOR in a stored procedure
Author Tim Ledgerwood
okokok - I've changed it, although for other reasons. However, your reason
makes sense. :-)

Each terminal in a retail environment has a terminal ID, and I need a
seperate TXN seq number for each. So now I have a table with the Terminal
ID and a TXN seq no for that terminal, and will increment them "manually"

So now I have a stored proc that goes like this :

CREATE PROCEDURE GETNEXTTXNSEQNO
(
TERMID VARCHAR(16)
)
RETURNS
(
RNEXTTXNSEQNO INTEGER
)
AS
BEGIN
FOR SELECT NEXTTXNSEQNO
FROM
TXNSEQNO
WHERE
TERMID = :TERMID
INTO
RNEXTTXNSEQNO
DO
BEGIN
RNEXTTXNSEQNO = RNEXTTXNSEQNO + 1;
UPDATE TXNSEQNO
SET
NEXTTXNSEQNO = :RNEXTTXNSEQNO
WHERE
TERMID = :TERMID;
SUSPEND;
END
END


At 06:32 PM 5/13/2003 +1000, you wrote:

>I my opinion your logic is wrong is you ever want to get the generator back
>without incrementing it... since other users can increment it without your
>knowledge, you can never be guaranteed of getting the value you think you
>are asking for.


[Non-text portions of this message have been removed]