Subject Creating a Trigger gives Error Msg: Invalid Column type: 0
Author Raymond Kennington
Creating a Trigger gives Error Msg: Invalid Column type: 0

Here's the relevant info:

CREATE TABLE Animal
(
ID INTEGER NOT NULL,
Name VARCHAR(20) NOT NULL,
Sex Char(1) NOT NULL,
"Sire ID" INTEGER,
"Dam ID" INTEGER
)

ALTER TABLE Animal ADD CONSTRAINT PK_Animal PRIMARY KEY (ID)

CREATE TRIGGER BI_GEN_ANIMAL_ID FOR ANIMAL
ACTIVE
BEFORE INSERT
POSITION 32767
AS
begin
if (new.ID is NULL) then
new.ID = gen_id(GEN_ANIMAL_ID, 1);
end

CREATE EXCEPTION EX_Sire_DNE 'Sire DNE';
CREATE EXCEPTION EX_Dam_DNE 'Dam DNE';

CREATE TRIGGER BI_CHECK_ANIMAL_SIRE FOR ANIMAL
ACTIVE
BEFORE INSERT
POSITION 1
AS
DECLARE VARIABLE ParentID INTEGER;
DECLARE VARIABLE ParentSex CHAR(1);
begin
if (NEW."Sire ID" IS NOT NULL) then
begin
SELECT ID, Sex FROM Animal WHERE (ID = NEW."Sire ID") INTO :ParentID, :ParentSex;

if (:ParentID IS NULL) then
begin
EXCEPTION EX_Sire_DNE;
end

if (:ParentSex <> 'M') then
begin
EXCEPTION EX_Sire_Invalid_Sex;
end
end
end

What's the problem?

TIA.
Raymond.
--
Raymond Kennington
Programming Solutions
W2W Team B