Subject | Tiggers and table constraints |
---|---|
Author | Steve Harp |
Post date | 2001-02-08T19:37:34Z |
Hi Guys,
How do I get IB to respect table constraints? For instance, I have the
following table:
CREATE TABLE xStore
(
StoreID Integer DEFAULT 0 NOT NULL,
StoreName varchar(25) NOT NULL,
StoreCode VarChar(25) DEFAULT '' NOT NULL,
LastUpdate TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (StoreID)
);
When I insert a record with StoreCode missing, I get an error message that
StoreCode is required; it should be populated with the default specified in
the metadata.
Also, I have triggers for insert and update which are not firing.
CREATE TRIGGER trgInsertStore FOR xStore
BEFORE INSERT POSITION 0
As BEGIN
EXCEPTION I_FIRED;
NEW.StoreID = GEN_ID(genStore, 100);
NEW.LastUpdate = CURRENT_TIMESTAMP;
END !!
When I use a TIBOQuery component to insert a record, the exception doesn't
fire.
I know that I can use GeneratorLinks to make generators fire, but I really
need triggers because they are capable of doing other cool stuff also like
updating the LastUpdate field with the timestamp. How can I get triggers to
fire?
Thanks,
Steve Harp
steve@...
How do I get IB to respect table constraints? For instance, I have the
following table:
CREATE TABLE xStore
(
StoreID Integer DEFAULT 0 NOT NULL,
StoreName varchar(25) NOT NULL,
StoreCode VarChar(25) DEFAULT '' NOT NULL,
LastUpdate TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (StoreID)
);
When I insert a record with StoreCode missing, I get an error message that
StoreCode is required; it should be populated with the default specified in
the metadata.
Also, I have triggers for insert and update which are not firing.
CREATE TRIGGER trgInsertStore FOR xStore
BEFORE INSERT POSITION 0
As BEGIN
EXCEPTION I_FIRED;
NEW.StoreID = GEN_ID(genStore, 100);
NEW.LastUpdate = CURRENT_TIMESTAMP;
END !!
When I use a TIBOQuery component to insert a record, the exception doesn't
fire.
I know that I can use GeneratorLinks to make generators fire, but I really
need triggers because they are capable of doing other cool stuff also like
updating the LastUpdate field with the timestamp. How can I get triggers to
fire?
Thanks,
Steve Harp
steve@...