Subject RE: [firebird-support] How to return generated value in TRIGGER ?
Author Ionut Ichim
Thanks.

"Returning" is what I'm looking for.

Thanks also to Martijn Tonies and Mercea Paul



ibrahim bulut <i.bulut@...> wrote: You can do it with firebird 2

Returning clause implemented for insert statements

See the release notes

Insert into table (field1,field2)

Returning field1, field2 into :field1, :field2 // psql

or

Insert into table (field1,field2)

Returning field1, field2 // dsql

_____

From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Martijn Tonies
Sent: Monday, June 18, 2007 11:59 AM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] How to return generated value in TRIGGER ?

Hi,

> I have a trigger on a table :
>
> CREATE TRIGGER TRIG_GS_PR_BI FOR GS_PR
> ACTIVE BEFORE INSERT POSITION 0
> AS
> BEGIN
> IF ((NEW.ID IS NULL) OR (NEW.ID =0)) THEN
> NEW.ID =NEXT VALUE FOR GEN_GS_PR_ID;
> END
>
> In my application I use a stored procedure to insert data,for ID I send 0
as the trigger to use generator.My problem is how to get the value written
in ID, I need it in my app after I call INSERT.Is there a simple way or a
have to query table for max(ID).
> Thanks !
>

If you don't supply "0" or "null" for the ID column, the trigger won't
do it's new value.

So, why not get a new value from the generator in the Stored Procedure
and return that to the client?

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene. <http://www.upscene.com> com
My thoughts:
http://blog. <http://blog.upscene.com/martijn/> upscene.com/martijn/
Database development questions? Check the forum!
http://www.database <http://www.databasedevelopmentforum.com>
developmentforum.com

__________ NOD32 2336 (20070618) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com

[Non-text portions of this message have been removed]






---------------------------------
Pinpoint customers who are looking for what you sell.

[Non-text portions of this message have been removed]