New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The trigger together with the operator MERGE if in a condition of connection ON contains new isn't compiled [CORE3753] #4097
Comments
Commented by: Sean Leyne (seanleyne) This was a support issue, which should have been posted to the support mailing list. The problem is that variables in DML/SQL statements need to be prefixed with ":". So, your statement should have read:
|
Commented by: @sim1984 Hasn't helped. |
Modified by: @asfernandesassignee: Adriano dos Santos Fernandes [ asfernandes ] |
Commented by: @asfernandes Dmitry, I saw this is not a MERGE problem. This SELECT causes the problem too: CREATE OR ALTER TRIGGER HORSE_AI FOR HORSE The problem was caused by commit done in 2010-01-19, then backported to 2.5 in 2010-11-13 and reworked (in 2.5 only) in 2010-11-19. Later in 2011-01-22 I refactored it, so it's now in RecordSourceNodes.cpp (comment - Set up an empty context to process the joins). BTW, CORE2812 is marked as fixed in 3.0 only, which I'm not sure since you committed the changes in 2.5 too. |
Modified by: @dyemanovassignee: Adriano dos Santos Fernandes [ asfernandes ] => Dmitry Yemanov [ dimitr ] |
Modified by: @dyemanovstatus: Open [ 1 ] => Resolved [ 5 ] resolution: Fixed [ 1 ] Fix Version: 3.0 Alpha 1 [ 10331 ] |
Commented by: @pcisar Test created. |
Modified by: @pcisarstatus: Resolved [ 5 ] => Closed [ 6 ] |
Submitted by: @sim1984
Is related to QA572
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
Commits: bcd483d
The text was updated successfully, but these errors were encountered: