Request:
Please explain why the CREATE TRIGGER statement throws
SQL0206 - Column or global variable PACKED_FLD not found
Sample Code:
CREATE TABLE TST_TABLE (
CHAR_FLD_ALIAS FOR COLUMN CHAR_FLD CHAR(9) CCSID 37 NOT NULL DEFAULT '',
PACKED_FLD_ALIAS FOR COLUMN PACKED_FLD DECIMAL(9, 0) NOT NULL DEFAULT 0,
ZONED_FLD_ALIAS FOR COLUMN ZONED_FLD NUMERIC(9, 0) NOT NULL DEFAULT 0 ,
DATE_FLD_ALIAS FOR COLUMN DATE_FLD DATE NOT NULL DEFAULT CURRENT_DATE,
TIME_FLD_ALIAS FOR COLUMN TIME_FLD TIME NOT NULL DEFAULT CURRENT_TIME,
TSTAMP_FLD_ALIAS FOR COLUMN TSTAMP_FLD TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY( CHAR_FLD_ALIAS ) )
CREATE TRIGGER TST_TRGPGM_LONG_NAME
NO CASCADE
BEFORE INSERT ON TST_TABLE
REFERENCING OLD AS o NEW AS n
FOR EACH ROW MODE DB2ROW
PROGRAM NAME TST_TRGPGM
BEGIN
SET n.PACKED_FLD = 999;
END
Complete Error Message:
Message ID . . . . . . : SQL0206 Severity . . . . . . . : 30 Message type . . . . . : Diagnostic
Message . . . . : Column or global variable PACKED_FLD not found.
Cause . . . . . : PACKED_FLD was not found as a column of table *N in *N and was not found as a global variable in *N. If the table is *N, PACKED_FLD is not a column of any table or view that can be referenced.Recovery . . . : Do one of the following and try the request again:
- Ensure that the column and table names are specified correctly in the statement.
- If this is a SELECT statement, ensure that all the required tables were named in the FROM clause.
- If the column was intended to be a correlated reference, qualify the column with the correct table designator.
- If the column was intended to be a global variable, qualify the name with the schema where the global variable exists or ensure the schema is in the path.
Reference Sites: