Board index » delphi » generators, ibtable - Insert via SQL works , append/post doesn't

generators, ibtable - Insert via SQL works , append/post doesn't

Hello IBX Gurus,

I have a table for storing customers information (below).
On the primary key (custid) I have definied a generator  and a trigger for
seting it .
Even tough this works absolutely fine when I do insert via SQL it doesn't
work
when I do ibtable.append and post or I use the dbnavigator's insert method.
It says custid must have a value !!!

Many thanks,
Gabor

/* Table: CUSTOMERS, Owner: SYSDBA */

CREATE TABLE "CUSTOMERS"
(
  "CUSTID" INTEGER NOT NULL,
  "CUSTNAME" VARCHAR(40),
  "CUSTADDR" VARCHAR(100),
  "CUSTPOBX" INTEGER,
  "CUSTCITY" VARCHAR(20),
  "CUSTCNTRY" VARCHAR(30),
  "CUSTCNTCT" VARCHAR(40),
  "CUSTEMAIL" VARCHAR(50),
  "CUSTUID" VARCHAR(20),
 PRIMARY KEY ("CUSTID")
);
SET TERM ^ ;

/* Triggers only will work for SQL triggers */

CREATE TRIGGER "INS_CUSTID" FOR "CUSTOMERS"
ACTIVE AFTER INSERT POSITION 0
as
Begin
  new.custID = GEN_ID(gencustID,1) ;
End
 ^

COMMIT WORK ^
SET TERM ;^

 

Re:generators, ibtable - Insert via SQL works , append/post doesn't


Quote
Gabor Faludi wrote:

> Hello IBX Gurus,

> I have a table for storing customers information (below).
> On the primary key (custid) I have definied a generator  and a trigger for
> seting it .
> Even tough this works absolutely fine when I do insert via SQL it doesn't
> work
> when I do ibtable.append and post or I use the dbnavigator's insert method.
> It says custid must have a value !!!

You need to instantiate the TFields and set custid's required field to false.
You are also going to find out fairly quickly that TIBTable is not a good
component for C/S work in general and for work with insert triggers than change
fields in specific.

--
Jeff Overcash (TeamB)
      (Please do not email me directly unless  asked. Thank You)
Anyone who cannot cope with mathematics is not fully human.
At best he is a tolerable subhuman who has learned to wear
shoes, bathe and not make messes in the house.   (Heinlein)

Other Threads