Post and Before Insert Trigger
Posted: Wed 10 Oct 2007 23:29
Hi,
having a FB table with a before insert trigger when inserting a new record and calling Post, the EDatabaseError occurs with message 'Field ID must have a value'. Actually I am using only TIBCQuery, TIBCDataSource, TDbGrid and TDbNavigator for calling Insert, entering data for the Num column only and calling Post.
But doing the same by the use of TIBCSQL with a statement inserts a new row without any error. Again, only the value for the NUM field is supplied.
I would like both - to use the before insert trigger for filling the primary key field ID and to call the TIBCQuery.Post method for posting the data. According to IBDAC help it should work. Please, any hint where am I making a mistake ?
having a FB table with a before insert trigger
Code: Select all
CREATE TABLE TABLEA (ID BIGINT NOT NULL,
NUM INTEGER NOT NULL);
CREATE TRIGGER TABLEA_BI FOR TABLEA
ACTIVE BEFORE INSERT POSITION 0
as
begin
if (new.id is null) then
new.id = gen_id(gen_tablea_id,1);
end
But doing the same by the use of TIBCSQL with a statement
Code: Select all
INSERT INTO tablea (Num) VALUES (:Num) RETURNING ID;
I would like both - to use the before insert trigger for filling the primary key field ID and to call the TIBCQuery.Post method for posting the data. According to IBDAC help it should work. Please, any hint where am I making a mistake ?