Subject | RE: [firebird-php] auto increment last insert |
---|---|
Author | Helen Borrie |
Post date | 2004-11-24T22:22:41Z |
At 09:01 AM 25/11/2004 +1100, you wrote:
by other applications at some point:
CREATE TRIGGER BI_tbl_test for tbl_test
ACTIVE BEFORE INSERT
AS
BEGIN
IF (new.int_ID IS NULL) THEN
new.int_ID = GEN_ID(gen_tbl_test, 1);
END ^
>I've just arrived in the office - did this thread get completed?For safety, you should also create a trigger, in case the database is used
>Is the original poster satisfied with the information?
>
>Basically, a set-by-step approach to replacing MySQL's autoinc, without
>procedures, triggers, and trying to get the value after the insert(could be
>inaccurate if the generator's been used since the insert...)
>
>This example will use the following simple table:
>CREATE TABLE tbl_test (
> int_ID NUMERIC(18,0) NOT NULL,
> str_name VARCHAR(100),
> PRIMARY KEY(int_ID)
>);
>/* This is the generator for the tbl_test table */
>CREATE GENERATOR gen_tbl_test;
by other applications at some point:
CREATE TRIGGER BI_tbl_test for tbl_test
ACTIVE BEFORE INSERT
AS
BEGIN
IF (new.int_ID IS NULL) THEN
new.int_ID = GEN_ID(gen_tbl_test, 1);
END ^