Subject Re: [firebird-php] using auto_number field
Author Dariusz Zelichowski
//Do it through storep procedures and triggers.


//Assume you have a table with a field:

CITY_GEN INTEGER;

//You want CITY_GEN to be auto incremented after every
insert.
//Create a Generator:

CREATE GENERATOR GEN_CITIES_ID;

//Set its value to 0

SET GENERATOR GEN_CITIES_ID TO 0;

//Create a trigger a Stored Procedure that will increment
the Genreator by 1

CREATE PROCEDURE SP_GEN_CITIES_ID
RETURNS (
ID INTEGER)
AS
BEGIN
ID = GEN_ID(GEN_CITIES_ID, 1);
END

//Now create the trigger to call the above procedure before
every INSERT operation:

CREATE TRIGGER CITIES_BI FOR CITIES
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.CITY_GEN IS NULL) THEN
NEW.CITY_GEN = GEN_ID(GEN_CITIES_ID,1);
END


That's all.



--- corp_5 <hasan@...> wrote:
> is there any way to use auto number field in FB ??
> maybe someone can help me,
>
> thankyou
>
>





__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/