Subject | Knowing the recent value of a generator |
---|---|
Author | Gustavo |
Post date | 2005-05-23T02:45:51Z |
Hello:
I use Delphi 5 and IBX.
I have a table TABLE1 with a field CODE1, a generator TABLE1_GEN_CODE1 and the next trigger:
CREATE TRIGGER TABLE1_SET_CODE1
FOR TABLE1
BEFORE INSERT AS
BEGIN
NEW.CODE1 = GEN_ID(TABLE1_GEN_CODE1, 1);
END;
After I make a Post of a new record in TABLE1, I want to know the value of the field CODE1 that was assigned by the generator but the field that "identifies" the record is just the field CODE1, so I can´t make a SELECT... WHERE CODE1=XXX because I don´t know the value of XXX.
I can make the next statement immediatly after the Post:
SELECT GEN_ID(TABLE1_GEN_CODE1,0) FROM TABLE1
and it works. But the question is: Is it possible that immediatly after my Post and before my SELECT another user makes a Post to TABLE1 incrementig the generator and then my SELECT obtains a value of the generator which is already incremented by one more than in my CODE1? If the answer is yes, then my next question is: How can I know the number assigned to fiele CODE1 immediatly after the INSERT statement?
I tried to be clear but I don´t know if this message is clear enough.
Thanks in advance
Gustavo
[Non-text portions of this message have been removed]
I use Delphi 5 and IBX.
I have a table TABLE1 with a field CODE1, a generator TABLE1_GEN_CODE1 and the next trigger:
CREATE TRIGGER TABLE1_SET_CODE1
FOR TABLE1
BEFORE INSERT AS
BEGIN
NEW.CODE1 = GEN_ID(TABLE1_GEN_CODE1, 1);
END;
After I make a Post of a new record in TABLE1, I want to know the value of the field CODE1 that was assigned by the generator but the field that "identifies" the record is just the field CODE1, so I can´t make a SELECT... WHERE CODE1=XXX because I don´t know the value of XXX.
I can make the next statement immediatly after the Post:
SELECT GEN_ID(TABLE1_GEN_CODE1,0) FROM TABLE1
and it works. But the question is: Is it possible that immediatly after my Post and before my SELECT another user makes a Post to TABLE1 incrementig the generator and then my SELECT obtains a value of the generator which is already incremented by one more than in my CODE1? If the answer is yes, then my next question is: How can I know the number assigned to fiele CODE1 immediatly after the INSERT statement?
I tried to be clear but I don´t know if this message is clear enough.
Thanks in advance
Gustavo
[Non-text portions of this message have been removed]