The trigger together with the operator MERGE if in a condition of connection ON 
contains new isn't compiled
-----------------------------------------------------------------------------------------------------------

                 Key: CORE-3753
                 URL: http://tracker.firebirdsql.org/browse/CORE-3753
             Project: Firebird Core
          Issue Type: Bug
          Components: Engine
    Affects Versions: 3.0 Alpha 1
         Environment: Windows 7, isql, fb 3.0.0.29768
            Reporter: Simonov denis


The trigger together with the operator MERGE if in a condition of connection ON 
contains new isn't compiled

CREATE TABLE HORSE (
    CODE_HORSE      INTEGER NOT NULL,
    CODE_FATHER     INTEGER DEFAULT -2 NOT NULL,
    CODE_MOTHER     INTEGER DEFAULT -3 NOT NULL,
    NAME            VARCHAR(50)
);

ALTER TABLE HORSE ADD CONSTRAINT PK_HORSE PRIMARY KEY (CODE_HORSE);

CREATE TABLE COVER (
    CODE_COVER        INTEGER NOT NULL,
    CODE_FATHER       INTEGER NOT NULL,
    CODE_MOTHER      INTEGER NOT NULL,
    CODE_HORSE        INTEGER NOT NULL
);

ALTER TABLE COVER ADD CONSTRAINT PK_COVER PRIMARY KEY (CODE_COVER);
ALTER TABLE COVER ADD CONSTRAINT FK_COVER_REF_FATHER FOREIGN KEY (CODE_FATHER) 
REFERENCES HORSE (CODE_HORSE);
ALTER TABLE COVER ADD CONSTRAINT FK_COVER_REF_HORSE FOREIGN KEY (CODE_HORSE) 
REFERENCES HORSE (CODE_HORSE) ;
ALTER TABLE COVER ADD CONSTRAINT FK_COVER_REF_MOTHER FOREIGN KEY (CODE_MOTHER) 
REFERENCES HORSE (CODE_HORSE);

CREATE OR ALTER TRIGGER HORSE_AI FOR HORSE
ACTIVE AFTER INSERT POSITION 0
AS
BEGIN
    MERGE INTO COVER
    USING RDB$DATABASE AS TBL
    ON COVER.CODE_FATHER = NEW.CODE_FATHER AND
       COVER.CODE_MOTHER = NEW.CODE_MOTHER
    WHEN MATCHED THEN
      UPDATE SET
      CODE_HORSE = NEW.CODE_HORSE
    WHEN NOT MATCHED THEN
      INSERT (CODE_HORSE,
              CODE_FATHER,
              CODE_MOTHER)
      VALUES (NEW.CODE_HORSE,
              NEW.CODE_FATHER,
              NEW.CODE_MOTHER);
  END
END^

Error: 

Statement failed, SQLSTATE = 42S22
unsuccefussful metadata update
-CREATE OR ALTER TRIGGER HORSE_AI failed
-Dynamic SQL Error
-SQL error code = -206
-Column unknown
-NEW.CODE_MOTHER

On Firebird 2.5 it worked

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to