Page 1 of 1

Get Oracle sequence field with active filter?

Posted: Thu 05 Nov 2009 04:37
by tobias_cd
Hi Plash,
I have a case where I'm using a filter condition on a TUniTable component (yeah, I know, I'd better be using TUniQuery :wink: ).
Upon Insert and Post obiously the table's (only) key field, filled by a sequence, obeys the filter condition in any case.
Is there a way or command to keep the filter, but still retrieve the last generated sequence after "Post" for that table anyway? Using ".Currval" manually gets me an ORA-08002 error at that point (due to the filter processing).
If not currently possible, I'd like to suggest to have a public property or method like "GetLastInsertId" or something.
Thank you,
Tobias

Posted: Fri 06 Nov 2009 10:10
by Plash
You should use CURRVAL to get the last value of a sequence.

You get ORA-08002 if you select CURRVAL before the sequence was used first time. After sequence was used (NEXTVAL selected), you can select CURRVAL.