Re: [Dbi-interbase-devel] DBD and Interbase functionality
Status: Beta
Brought to you by:
edpratomo
From: Mark D. A. <md...@di...> - 2002-04-30 15:54:01
|
> There seems to be one difference: you cannot get the "current" value > from a generator. For instance, from a sequence you can do: > > INSERT INTO foo ( id ) VALUES ( NEXTVAL( seq ) ); > SELECT CURRVAL( seq ); Yes, and no, i think: you can do that also in interbase, but with both oracle and interbase, that approach only works if you wrap it all in one transactional context, for example in a stored procedure body. To read the current value of an interbase generator SELECT GEN_ID(seq,0) from RDB$DATABASE will get you the current value of the generator called "seq" (last i checked interbase does not support a select statement without a "from" clause). In my own home-grown SPOPS, i work around the problem of a standards-based insert not returning anything, by issuing one sql request to get a unique value of a generator, and then just using that value in a later insert (in a separate transaction context). generators are guaranteed (like sequences) to never repeat a value. this approach has the downside of having two roundtrips, but it has the upside of working on every rdbms. it also has the characteristic of potentially skipping some values in the sequence, but i don't care about that. -mda |