Subject | Re: Generators questions |
---|---|
Author | m24paul |
Post date | 2007-04-30T18:47:48Z |
Because GEN_ID increment with 1 your generator, for each record in
your table. and show it !
If u need a 'autoincrement' field you shoud create a trigger for that:
if your database is Dialect 3:
CREATE TRIGGER TABLE1_SEQ FOR TABLE1
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.IDDOC IS NULL) THEN
NEW.IDDOC = next value for GEN_N;
END
if your database is Dialect 1:
CREATE TRIGGER TABLE1_SEQ FOR TABLE1
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.IDDOC IS NULL) THEN
NEW.IDDOC = GEN_ID(GEN_N,1);
END
Regards,
Paul
--- In firebird-support@yahoogroups.com, Ionut Ichim <ionut_ykm@...>
wrote:
your table. and show it !
If u need a 'autoincrement' field you shoud create a trigger for that:
if your database is Dialect 3:
CREATE TRIGGER TABLE1_SEQ FOR TABLE1
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.IDDOC IS NULL) THEN
NEW.IDDOC = next value for GEN_N;
END
if your database is Dialect 1:
CREATE TRIGGER TABLE1_SEQ FOR TABLE1
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.IDDOC IS NULL) THEN
NEW.IDDOC = GEN_ID(GEN_N,1);
END
Regards,
Paul
--- In firebird-support@yahoogroups.com, Ionut Ichim <ionut_ykm@...>
wrote:
>a generator
> I've created a table (table1) with IDcod as pk numeric(18,0),then
>generated.
>
>
> CREATE GENERATOR GEN_N;
>
> SET GENERATOR GEN_N TO 1;
>
>
>
> I've inserted 3 records for IDcod values 5,6,7.
>
> With IBExpert Personal,in a script I put this :
>
>
>
>
>
> SELECT gen_id(gen_N,1) FROM table1;
>
>
>
> Result :
>
> 2 3 4
>
> run again
>
> 5 6 7
>
>
>
> Why generator creates such result, for each record a value
> Where is the value i look for ?generator from the start ?
> Wouldn't it be slow for a big database ?
>
> Why generator creates values that can duplicate pk,or I have to use
>
> Thanks.
>
>
>
>
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> [Non-text portions of this message have been removed]
>