Ambiguous field name in the trigger when it does a select from the table
------------------------------------------------------------------------

                 Key: CORE-3883
                 URL: http://tracker.firebirdsql.org/browse/CORE-3883
             Project: Firebird Core
          Issue Type: Bug
          Components: Engine
    Affects Versions: 3.0 Initial
            Reporter: Simonov Denis


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);

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 copile success.

-- 
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

        

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to