Get Oracle sequence field with active filter?

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
tobias_cd
Posts: 56
Joined: Thu 18 Dec 2008 22:10

Get Oracle sequence field with active filter?

Post by tobias_cd » Thu 05 Nov 2009 04:37

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

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 06 Nov 2009 10:10

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.

Post Reply