Subject Re: [firebird-support] How to return generated value in TRIGGER ?
Author Ionut Ichim
I'm resending this message because yahoo didn't send
it,or delayed it.

Thanks.
"Returning" is what I was looking for.
Thans also to Martijn Tonies and Mercea Paul.


ibrahim 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%40yahoogroups.com>
> [mailto:firebird-support@yahoogroups.com
> <mailto:firebird-support%40yahoogroups.com>] On
Behalf Of Martijn Tonies
> Sent: Monday, June 18, 2007 11:59 AM
> To: firebird-support@yahoogroups.com
> <mailto:firebird-support%40yahoogroups.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
<http://www.upscene.com>> com
> My thoughts:
> http://blog. <http://blog.upscene.com/martijn/
> <http://blog.upscene.com/martijn/>>
upscene.com/martijn/
> Database development questions? Check the forum!
> http://www.database
<http://www.databasedevelopmentforum.com
> <http://www.databasedevelopmentforum.com>>
> developmentforum.com
>
> __________ NOD32 2336 (20070618) Information
__________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com <http://www.eset.com>
>
> [Non-text portions of this message have been
removed]
>
>




____________________________________________________________________________________
Got a little couch potato?
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz