Subject | after updates |
---|---|
Author | |
Post date | 2014-07-12T21:31:28Z |
i know i am probably the last holdout from v1.5 to v2.5. i am currently using 2.5.2.26540. i have been distracted.
i have narrowed my problem down to an AFTER UPDATE trigger. essentially, i can not update a table, called RC_1, unless i have inactivated or deleted an AFTER UPDATE, but it is a little complicated.
here is the RC_1 metadata:
TABLE: RC_1, FIELDS:
CODE_1 RDB$118 CHAR(2) NOT NULL
DESCRIPTION D_DESCRIPTION VARCHAR(30) NOT NULL
CREATE TRIGGER RC_1_AU FOR RC_1 AFTER UPDATE
AS
BEGIN
IF (OLD.CODE_1 <> NEW.CODE_1) THEN BEGIN
UPDATE RC_2 SET CODE_1 = NEW.CODE_1 WHERE (CODE_1 = OLD.CODE_1);
UPDATE EXRORC SET RC = STR_EXTRACT_REPLACE(RC,NEW.CODE_1,'-',1) WHERE (STR_COPY(RC,1,2) = OLD.CODE_1);
UPDATE PMVMRS SET RC = STR_EXTRACT_REPLACE(RC,NEW.CODE_1,'-',1) WHERE (STR_COPY(RC,1,2) = OLD.CODE_1);
UPDATE ROVMRS SET RC = STR_EXTRACT_REPLACE(RC,NEW.CODE_1,'-',1) WHERE (STR_COPY(RC,1,2) = OLD.CODE_1);
UPDATE ZHSTYEQ_RC SET RC = STR_EXTRACT_REPLACE(RC,NEW.CODE_1,'-',1) WHERE (STR_COPY(RC,1,2) = OLD.CODE_1);
UPDATE ZRC_DATA SET RC = STR_EXTRACT_REPLACE(RC,NEW.CODE_1,'-',1) WHERE (STR_COPY(RC,1,2) = OLD.CODE_1);
UPDATE ZRC_VMRS SET RC = STR_EXTRACT_REPLACE(RC,NEW.CODE_1,'-',1) WHERE (STR_COPY(RC,1,2) = OLD.CODE_1);
END
END~
where the STR_EXTRACT_REPLACE and STR_COPY are in a UDF with the proper bit structure to match firebird, i.e., both are 64-bit, and the UDFs work great and without issue.
in the calling application, the isc_dsql_prepare function will return the error/exception: "attempted update of read-only column". but only if the UPDATE ROVMRS .... line is present in the above trigger. the presence of all the other lines don't return the error from the calling application.
if i go one step further and inactivate the AFTER UPDATE trigger for ROVMRS and include UPDATE ROVMRS .... the line in the above trigger, i will also NOT get the error.
so i get the error if the AFTER UPDATE trigger is active for the ROVMRS table, but that trigger has no reference to the RC field which is getting changed within it. so i don't get it.
here is also the AFTER UPDATE trigger for the ROVMRS table:
CREATE TRIGGER ROVMRS_AU FOR ROVMRS AFTER UPDATE
AS
DECLARE VARIABLE ff SMALLINT;
BEGIN
SELECT FIRING FROM TRIGGER_CONTROL WHERE EVENT = "GL_UPDATE" INTO :ff;
IF ((OLD.GL = NEW.GL) AND (:ff = 0)) THEN BEGIN
IF (OLD.RCHARGE <> NEW.RCHARGE) THEN BEGIN
UPDATE ROMECH M SET M.RCHARGE = NEW.RCHARGE WHERE (M.IDIV = NEW.IDIV) AND (M.IRO = NEW.IRO) AND (M.IROVMRS = NEW.IC_ROVMRS);
UPDATE ROPART P SET P.RCHARGE = NEW.RCHARGE WHERE (P.IDIV = NEW.IDIV) AND (P.IRO = NEW.IRO) AND (P.IROVMRS = NEW.IC_ROVMRS);
END
EXECUTE PROCEDURE TRGR_UPDATE_PMEVENT_CURRENT(NEW.IDIV,NEW.IRO,"I");
END /*IF ((OLD.GL = NEW.GL) AND (:ff = 0))...*/
END~
where the stored procedure TRGR_UPDATE_PMEVENT_CURRENT also has absolutely no reference to the RC field being updated in the original RC_1 trigger.
so i don't get why firebird is throwing back this error nor do i understand how to address it.
thanx in advance and have a great day. lucas