Subject | Re: [firebird-support] Re: procedure question or multiple table keys |
---|---|
Author | Helen Borrie |
Post date | 2004-06-01T07:40:17Z |
At 07:30 AM 1/06/2004 +0000, you wrote:
If you want your key in the application and it uses gen_Something, this
drop-dead-simple query will allow you to fetch the latest generator value
into an application variable:
select gen_id(gen_Something, 1) from rdb$database;
Just read the resultset of this query into your variable and you've got
it. As long as you post the "master" record first, you can create
"details" with this value as their foreign key in the same transaction, to
your heart's content.
/heLen
> > If you wish that all records have the same key on multiple tables, theQuerying the database for a generator value is not a new feature at all.
> > best you can do, is retrieve the key number and put that on your insert
> > statements.
> >
> > If you use generator, you cannot ask for the value after you insert,
> > since this value could be changed by other actions. Retrieve it first
> > and use it in everywhere you wish.
> >
> > see you !
> >
> >Thanks Alexandre, I looked at the Release Notes for 15 and 'think' I
>understand that what I want to do may work, except for one reason. I'm
> using ADOdb and i don't think that this new feature is in that as
>yet, or I'm not even certain that procedures can be executed either,
>so I still have a problem that I don't know how to resolve. Thanks.
If you want your key in the application and it uses gen_Something, this
drop-dead-simple query will allow you to fetch the latest generator value
into an application variable:
select gen_id(gen_Something, 1) from rdb$database;
Just read the resultset of this query into your variable and you've got
it. As long as you post the "master" record first, you can create
"details" with this value as their foreign key in the same transaction, to
your heart's content.
/heLen