database - Command to get identity of newly inserted record in Interbase 2007 -


in interbase (i'm using 2007, don't know if matters) there command identity of newly-inserted record, similar scope_identity() in sql server?

no, interbase doesn't have identity feature.

what interbase has, instead, generator feature. generators kind of identity, logically separated primary key column. generator, in other words, give guaranteed unique value, value you.

you use value primary key values single table, or multiple tables. assigning primary key value must yourself.

in addition not having feature scope_identity, interbase not have kind of feature return values insert statement. not can not generated primary key value insert statement, cannot other values, such values set trigger.

workarounds

one possible workaround generate primary key value in advance. following (i'm going use interbase stored procedure syntax example, since don't know programming language using, can same thing in programming language):

declare variable id integer; begin     id = select gen_id(my_generator, 1) rdb$database;     insert my_table (id, description) values (:id, "foo"); 

rdb$database system table has 1 record. knowing value of id, can return proc.

a second workaround select record using alternate key , read generated id way.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -