Subject | Re: [ib-support] Re: Trigger problem |
---|---|
Author | Helen Borrie |
Post date | 2001-10-08T03:12:17Z |
At 10:53 PM 07-10-01 +0000, Dave wrote:
You can use a stored procedure to do your insert, explicitly firing the generator and returning the value as an an output parameter, viz.
create procedure mytable_update(<input parameter list>)
returns(newpk numeric(18,0))
as
begin
newpk := gen_id(mygenerator, 1);
insert into mytable (<column list>)
values (newpk,<parameter list>);
end
Another approach is to get the generated value into your application before you do the insert. Just write a function that returns the generator to your application as
Result = select gen_id(mygenerator, 1) from rdb$database
If you are using any of the IB-specific data access tools in your development (IB Objects, FreeIBPlus, IBX, IBPerl) there are encapsulations of generator-related stuff already available.
When you post questions here, it's a really good idea to describe your development environment. That way, there will be folk who can give you specific advice.
regards,
Helen
>Okay (Someways thought I couldn't) BUT I am using IBConsole and wouldThere are various ways.
>like to do an auto-refresh on the table.
>
>So if i cannot do it via commit retain in a stored procedure or
>trigger after a value has been placed into a field via a generator.
>
>How can it be done ?????
You can use a stored procedure to do your insert, explicitly firing the generator and returning the value as an an output parameter, viz.
create procedure mytable_update(<input parameter list>)
returns(newpk numeric(18,0))
as
begin
newpk := gen_id(mygenerator, 1);
insert into mytable (<column list>)
values (newpk,<parameter list>);
end
Another approach is to get the generated value into your application before you do the insert. Just write a function that returns the generator to your application as
Result = select gen_id(mygenerator, 1) from rdb$database
If you are using any of the IB-specific data access tools in your development (IB Objects, FreeIBPlus, IBX, IBPerl) there are encapsulations of generator-related stuff already available.
When you post questions here, it's a really good idea to describe your development environment. That way, there will be folk who can give you specific advice.
regards,
Helen