Subject RE: [firebird-support] Re: Auto Incrementing field
Author Richard Pendered
What you should do is to get the next generator value first (select gen_d(
generator,1 ) from rdb$database), then use that in your insert statement. If
you have made use of the extra checks by Alex Taylor, it shoudl work as
expected.
Be aware that calls to gen_id are not under transaction control, and are
therefore safe to use like this as you will not get duplicates (assumung you
use a step of more than 0).

-----Original Message-----
From: benmarron [mailto:colletb@...]
Sent: 10 December 2003 08:42
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Re: Auto Incrementing field


--- In firebird-support@yahoogroups.com, Bahadir ARMAGAN
<barmagan@t...> wrote:
> Thank you for your explanation. I did it.
> Now how can I get this auto generated vaule when I insert records? I
have an
> example for mssql server which uses @@IDENTITY for returning this value.
> Does it work for firebird?
> Should I start a new message thread for this?
>

I think Gen_id function can do this job.

Syntax is : gen_id ( generator, step)

If you set argument "step" to 1, the function increment the generator
by 1 and returns the value of the generator.

If you set argument "step" to 0, the function returns the value of the
generator without increment or decrement.





To unsubscribe from this group, send an email to:
firebird-support-unsubscribe@yahoogroups.com



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/