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
Ambiguous field name in the trigger when it does a select from the table [CORE3883] #4220
Comments
Modified by: @sim1984description: CREATE TABLE REGTYPE ( ALTER TABLE REGTYPE ADD CONSTRAINT PK_REGTYPE PRIMARY KEY (CODE_REGTYPE); CREATE TABLE REG ( ALTER TABLE REG ADD CONSTRAINT PK_REG PRIMARY KEY (CODE_REG); SET TERM ^ ; /* Trigger: REG_BI0 */ SET TERM ; ^ unsuccessful metadata update. In Firebird 2.5.2 this trigger copile success. => CREATE TABLE REGTYPE ( ALTER TABLE REGTYPE ADD CONSTRAINT PK_REGTYPE PRIMARY KEY (CODE_REGTYPE); CREATE TABLE REG ( ALTER TABLE REG ADD CONSTRAINT PK_REG PRIMARY KEY (CODE_REG); SET TERM ^ ; /* Trigger: REG_BI0 */ SET TERM ; ^ unsuccessful metadata update. In Firebird 2.5.2 this trigger compile success. |
Modified by: @sim1984description: CREATE TABLE REGTYPE ( ALTER TABLE REGTYPE ADD CONSTRAINT PK_REGTYPE PRIMARY KEY (CODE_REGTYPE); CREATE TABLE REG ( ALTER TABLE REG ADD CONSTRAINT PK_REG PRIMARY KEY (CODE_REG); SET TERM ^ ; /* Trigger: REG_BI0 */ SET TERM ; ^ unsuccessful metadata update. In Firebird 2.5.2 this trigger compile success. => CREATE TABLE REGTYPE ( ALTER TABLE REGTYPE ADD CONSTRAINT PK_REGTYPE PRIMARY KEY (CODE_REGTYPE); CREATE TABLE REG ( ALTER TABLE REG ADD CONSTRAINT PK_REG PRIMARY KEY (CODE_REG); CREATE EXCEPTION E_DUPLICATE_REG 'Duplicate registration info'; SET TERM ^ ; /* Trigger: REG_BI0 */ SET TERM ; ^ unsuccessful metadata update. In Firebird 2.5.2 this trigger compile success. |
Modified by: @asfernandesassignee: Adriano dos Santos Fernandes [ asfernandes ] |
Commented by: Sean Leyne (seanleyne) What happens if to add ":" in front of the NEW. references, as in: CREATE OR ALTER TRIGGER REG_BI0 FOR REG Please try this syntax and report back. |
Commented by: @sim1984 This syntax don't compile. Error message: Dynamic SQL Error. |
Modified by: @asfernandesstatus: Open [ 1 ] => Resolved [ 5 ] resolution: Fixed [ 1 ] Fix Version: 3.0 Alpha 1 [ 10331 ] |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Resolved [ 5 ] QA Status: Done successfully Test Details: Provided code works fine on FB >= 2.0.7. |
Commented by: @pcisar Test created. |
Modified by: @pcisarstatus: Resolved [ 5 ] => Closed [ 6 ] |
Submitted by: @sim1984
Is related to QA575
CREATE TABLE REGTYPE (
CODE_REGTYPE INTEGER NOT NULL,
NAME VARCHAR(20),
MULTIRECORD SMALLINT
);
ALTER TABLE REGTYPE ADD CONSTRAINT PK_REGTYPE PRIMARY KEY (CODE_REGTYPE);
CREATE TABLE REG (
CODE_REG INTEGER NOT NULL,
CODE_REGTYPE INTEGER,
CODE_HORSE INTEGER
);
ALTER TABLE REG ADD CONSTRAINT PK_REG PRIMARY KEY (CODE_REG);
CREATE EXCEPTION E_DUPLICATE_REG 'Duplicate registration info';
SET TERM ^ ;
/* Trigger: REG_BI0 */
CREATE OR ALTER TRIGGER REG_BI0 FOR REG
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (EXISTS(SELECT 1
FROM REG
INNER JOIN REGTYPE ON REG.CODE_REGTYPE = REGTYPE.CODE_REGTYPE
WHERE REG.CODE_HORSE = NEW.CODE_HORSE AND
REG.CODE_REGTYPE = NEW.CODE_REGTYPE AND
REGTYPE.MULTIRECORD = 0)) THEN
EXCEPTION E_DUPLICATE_REG;
END
^
SET TERM ; ^
unsuccessful metadata update.
CREATE OR ALTER TRIGGER REG_BI0 failed.
Dynamic SQL Error.
SQL error code = -204.
Ambiguous field name between table REG and table REG .
In Firebird 2.5.2 this trigger compile success.
Commits: fd10a7e
====== Test Details ======
Provided code works fine on FB >= 2.0.7.
The text was updated successfully, but these errors were encountered: