Subject | Re: [ib-support] Creating a Trigger gives Error Msg: Invalid Column type: 0 |
---|---|
Author | Raymond Kennington |
Post date | 2002-11-15T10:07:16Z |
Alan McDonald wrote:
have dozens of other triggers to add.
Raymond Kennington
Programming Solutions
W2W Team B
>The 2nd trigger.
> Raymond,
> which trigger gives the error,
> and can I ask why you set the position of the pk trigger so high?The generator trigger should only occur after all triggers have fired successfully and I
have dozens of other triggers to add.
> 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