Subject | Re: [firebird-php] Re: using auto_number field |
---|---|
Author | Jean Lopes - TSA |
Post date | 2004-06-04T14:17:17Z |
remember that when you use trigger to implements auto-inc field, you don´t
have control over the
value. It is a problem qhen you use master-detail relationships. In my
databases mny trigger had a
test. If de value of a auto-inc is null or 0 (zero) then get a new
generator, othewise the aplication
get the generator first and, with the value "in hands", send it to database
in the insert command. then
I had the key value for details.
Diferents problems requires diferents solutions. One touch wizzard always
resolves thr problems
in the same way.
Jean Paul Lopes
Sócio-Gerente
TSA Tecnologia Sistemas e Automação Ltda.
http://www.tsa-sistemas.com.br
Rua Cel Sarmento, 1699 / 101
94010-031 - Gravataí - RS
Fone/Fax: 51 488.3608 / 3042.6084
Membro da Comunidade Firebird de Língua Portuguesa
Member of Portuguese Spoken Firebird Comunity - CFLP
http://www.comunidade-firebird.org
Fazendo o Firebird falar português
Making Firebird speaks portuguese
jean.lopes@...
have control over the
value. It is a problem qhen you use master-detail relationships. In my
databases mny trigger had a
test. If de value of a auto-inc is null or 0 (zero) then get a new
generator, othewise the aplication
get the generator first and, with the value "in hands", send it to database
in the insert command. then
I had the key value for details.
Diferents problems requires diferents solutions. One touch wizzard always
resolves thr problems
in the same way.
Jean Paul Lopes
Sócio-Gerente
TSA Tecnologia Sistemas e Automação Ltda.
http://www.tsa-sistemas.com.br
Rua Cel Sarmento, 1699 / 101
94010-031 - Gravataí - RS
Fone/Fax: 51 488.3608 / 3042.6084
Membro da Comunidade Firebird de Língua Portuguesa
Member of Portuguese Spoken Firebird Comunity - CFLP
http://www.comunidade-firebird.org
Fazendo o Firebird falar português
Making Firebird speaks portuguese
jean.lopes@...
----- Original Message -----
From: "Alan McDonald" <alan@...>
To: <firebird-php@yahoogroups.com>
Sent: Friday, June 04, 2004 10:47 AM
Subject: RE: [firebird-php] Re: using auto_number field
> yes, this is the fast way to create, since no built-in function
> on auto number field, anyway thanks for your helping....
>
> the good amdin tools do all this for you - you just create the field and
> say - make it a PK, create a generator for it or use an existing one, tick
> boxes and OK
>
> see IBExpert or DatabaseWorkbench
>
> Alan
>
> --- In firebird-php@yahoogroups.com, Dariusz Zelichowski
> <z_darius@y...> wrote:
> > //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@d...> 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/
>
>
> Yahoo! Groups Sponsor
> ADVERTISEMENT
>
>
>
>
>
>
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/firebird-php/
>
> To unsubscribe from this group, send an email to:
> firebird-php-unsubscribe@yahoogroups.com
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>