Subject Re: [firebird-support] Autonumeric columns
Author Miroslav Penchev
On Tue, 19 Oct 2004 11:32:43 -0500, Flores José
<jflores@...> wrote:

> Hello,
>
> I'm moving to Firebird
>
>
>
> At MS SQL i have an option to create autonumeric columns
>
> With this: IDENTITY (seed, increment )
> ...
> How can I do the same with Firebird?

With triggers and generators like this:

CREATE GENERATOR GEN_ADDRESS_ID;

SET TERM ^ ;

CREATE TRIGGER ADDRESS_BI_BI FOR ADDRESS
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.ADDRESS_ID IS NULL) THEN
NEW.ADDRESS_ID = GEN_ID(GEN_ADDRESS_ID,1);
END
^
SET TERM ; ^

--
Miroslav Penchev