If you are using firebird 2.0 or greater, you can use the *RETURNING *clause:

/insert into my_table (trabajo, contratista, idgestion) values ('abc', 'abc', 1) RETURNING idtrabajo/

But you will have to use ExecuteScalar(), not ExecuteNonQuery to get the returning value.


leo



Jose Perez wrote:
Well. I have an insertion on a table like this:

idtrabajo --- integer autoincremet primary key
trabajo -- varchar
contratista -- varchar
idgestion -- integer

I do the insertion with a FbCommand and ExecuteNonQuery.
But now I want to know the "idtrabajo" for the inserted element, cause I need it to pass it to another form. I need to pass it to another form cause I have another table that uses this "idtrabajo" as a foreign key, and I need it to make the insertions on that other table. Is there an easy way to do it other than do a select query after the insert??

Thanks!

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to