Subject | Re: [firebird-support] get to AutoInc value |
---|---|
Author | Martijn Tonies |
Post date | 2004-10-15T16:23:54Z |
Hello,
The best thing you can do is:
CREATE PROCEDURE myproc (input) RETURNS (newkey integer)
AS...
...
newkey = gen_id(mygenerator, 1);
insert into mytables ... values (:newkey, lots of input parameters);
end
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com
> I use a stored procedure to insert data into a table. In the table aNo.
> field is autoincremented. Is it possible to return the value of this
> field by this stored procedure?
> Or do I've to query the database for knowing the autoincremented value?You cannot do this in a decent way in a multi-user system.
The best thing you can do is:
CREATE PROCEDURE myproc (input) RETURNS (newkey integer)
AS...
...
newkey = gen_id(mygenerator, 1);
insert into mytables ... values (:newkey, lots of input parameters);
end
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com