Ie I have this table:
Code: Select all
CREATE TABLE MAPS (
ID INTEGER NOT NULL,
DESCRIPTION VARCHAR(255) CHARACTER SET UTF8 COLLATE UTF8);
ALTER TABLE MAPS ADD PRIMARY KEY (ID);
CREATE GENERATOR MAPS_ID_GEN
SET GENERATOR MAPS_ID_GEN TO 0
CREATE TRIGGER BI_MAPS_ID FOR MAPS
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.ID IS NULL) THEN
NEW.ID = GEN_ID(MAPS_ID_GEN, 1);
END
I also created a trigger so I dont have to worry about the ID's.
If I insert data with a query:
Code: Select all
INSERT INTO maps (id,description) VALUES(null,'test')
But I dont use querys everywhere, sometimes I just use a good old Table.
So I want to do this:
Code: Select all
MapsTable.Append;
MapsTable.FieldByName('ID').AsInteger:=null;
MapsTable.FieldByName('Description').AsString:='test';
MapsTable.Post;
Do I leave the whole line I get: ID must have a value.
Do I set .AsInteger=0 the ID's will be 0, obviously.
But how to do it right then? How to get it on NULL?
Anyone an idea?