Discussion:
How to use Trigger for auto-increment fields
(too old to reply)
pcerdaz
2007-07-02 02:39:47 UTC
Permalink
Hi, I need an autoincrement field but next method does not work.
What is missing?

CREATE TRIGGER "T_BI_CODIGOFACTURA" FOR "FACTURASCOMPRAS"
ACTIVE BEFORE INSERT POSITION 0
as
begin
FACTURASCOMPRAS.CODIGOFACTURA = GEN_ID(G_CODIGOFACTURA, 1);
end

Thank you,
pcerdaz
Jeff Overcash (TeamB)
2007-07-02 06:06:51 UTC
Permalink
Post by pcerdaz
Hi, I need an autoincrement field but next method does not work.
What is missing?
CREATE TRIGGER "T_BI_CODIGOFACTURA" FOR "FACTURASCOMPRAS"
ACTIVE BEFORE INSERT POSITION 0
as
begin
FACTURASCOMPRAS.CODIGOFACTURA = GEN_ID(G_CODIGOFACTURA, 1);
end
Thank you,
pcerdaz
This should be

CREATE TRIGGER "T_BI_CODIGOFACTURA" FOR "FACTURASCOMPRAS"
ACTIVE BEFORE INSERT POSITION 0
as
begin
new.CODIGOFACTURA = GEN_ID(G_CODIGOFACTURA, 1);
end
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
pcerdaz
2007-07-02 14:14:08 UTC
Permalink
Unfortunately the Trigger still is not working. I'm trying to insert a new
record with IBConsole from where I insert the new record, then I populate
the data (without the auto-increment field), but at the moment of post is
rejected because "The 'auto-increment' field must have a value". The same
problem happen through the application.

May be the problem is with field: it is an Integer with No Allow Nulls.


Any idea would be gratefully,
pcerdaz
Post by Jeff Overcash (TeamB)
Post by pcerdaz
Hi, I need an autoincrement field but next method does not work.
What is missing?
CREATE TRIGGER "T_BI_CODIGOFACTURA" FOR "FACTURASCOMPRAS"
ACTIVE BEFORE INSERT POSITION 0
as
begin
FACTURASCOMPRAS.CODIGOFACTURA = GEN_ID(G_CODIGOFACTURA, 1);
end
Thank you,
pcerdaz
This should be
CREATE TRIGGER "T_BI_CODIGOFACTURA" FOR "FACTURASCOMPRAS"
ACTIVE BEFORE INSERT POSITION 0
as
begin
new.CODIGOFACTURA = GEN_ID(G_CODIGOFACTURA, 1);
end
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Jeff Overcash (TeamB)
2007-07-02 21:12:50 UTC
Permalink
Post by pcerdaz
Unfortunately the Trigger still is not working. I'm trying to insert a new
record with IBConsole from where I insert the new record, then I populate
the data (without the auto-increment field), but at the moment of post is
rejected because "The 'auto-increment' field must have a value". The same
problem happen through the application.
May be the problem is with field: it is an Integer with No Allow Nulls.
Different problem. On the VCL side you will need to set the required property
to false for that TField.
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted corridors of Whitehall.
(Fish)
Loading...