Subject | RE: [firebird-support] attempted update of read only field |
---|---|
Author | Mercea Paul |
Post date | 2008-07-28T21:50:33Z |
Try to run trigger as Before Update!
Regards,
Paul
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Stephen Boyd
Sent: 28 July 2008 23:49
To: firebird-support@yahoogroups.com
Subject: [firebird-support] attempted update of read only field
When attempting to create a trigger on a table in Firebird 2.0.3 using
ISQL I get the following error:
Statement failed, SQLCODE = -151
attempted update of read-only column
After line 1 in file c:\swbtemp\test.sql
The DDL to create the trigger is as follows:
SET TERM ^ ;
CREATE TRIGGER LDS_AFTER_UPDATE FOR LD_STOP
AFTER UPDATE POSITION 0
AS
BEGIN
/* If any of the EDI sensitive dates have changed, then clear the
'214'
date to force the EDI status update to be sent again. */
IF (OLD.LDS_APPT_DATE_LOW IS NULL AND NEW.LDS_APPT_DATE_LOW IS NOT
NULL) THEN
BEGIN
NEW.LDS_APPT_214_DATE = NULL;
END
IF (OLD.LDS_APPT_DATE_LOW <> NEW.LDS_APPT_DATE_LOW) THEN
BEGIN
NEW.LDS_APPT_214_DATE = NULL;
END
IF (OLD.LDS_ACT_ARI_DATE IS NULL AND NEW.LDS_ACT_ARI_DATE IS NOT
NULL) THEN
BEGIN
NEW.LDS_ARI_214_DATE = NULL;
END
IF (OLD.LDS_ACT_ARI_DATE <> NEW.LDS_ACT_ARI_DATE) THEN
BEGIN
NEW.LDS_ARI_214_DATE = NULL;
END
IF (OLD.LDS_ACT_BIN_DATE IS NULL AND NEW.LDS_ACT_BIN_DATE IS NOT
NULL) THEN
BEGIN
NEW.LDS_BIN_214_DATE = NULL;
END
IF (OLD.LDS_ACT_BIN_DATE <> NEW.LDS_ACT_BIN_DATE) THEN
BEGIN
NEW.LDS_BIN_214_DATE = NULL;
END
IF (OLD.LDS_ACT_REL_DATE IS NULL AND NEW.LDS_ACT_REL_DATE IS NOT
NULL) THEN
BEGIN
NEW.LDS_REL_214_DATE = NULL;
END
IF (OLD.LDS_ACT_REL_DATE <> NEW.LDS_ACT_REL_DATE) THEN
BEGIN
NEW.LDS_REL_214_DATE = NULL;
END
IF (OLD.LDS_ACT_DEP_DATE IS NULL AND NEW.LDS_ACT_DEP_DATE IS NOT
NULL) THEN
BEGIN
NEW.LDS_DEP_214_DATE = NULL;
END
IF (OLD.LDS_ACT_DEP_DATE <> NEW.LDS_ACT_DEP_DATE) THEN
BEGIN
NEW.LDS_DEP_214_DATE = NULL;
END
END
^
This works perfectly in all FB 1.x versions. Have I found a bug in FB
2 or has something changed that I don't know about?
Regards,
Paul
From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Stephen Boyd
Sent: 28 July 2008 23:49
To: firebird-support@yahoogroups.com
Subject: [firebird-support] attempted update of read only field
When attempting to create a trigger on a table in Firebird 2.0.3 using
ISQL I get the following error:
Statement failed, SQLCODE = -151
attempted update of read-only column
After line 1 in file c:\swbtemp\test.sql
The DDL to create the trigger is as follows:
SET TERM ^ ;
CREATE TRIGGER LDS_AFTER_UPDATE FOR LD_STOP
AFTER UPDATE POSITION 0
AS
BEGIN
/* If any of the EDI sensitive dates have changed, then clear the
'214'
date to force the EDI status update to be sent again. */
IF (OLD.LDS_APPT_DATE_LOW IS NULL AND NEW.LDS_APPT_DATE_LOW IS NOT
NULL) THEN
BEGIN
NEW.LDS_APPT_214_DATE = NULL;
END
IF (OLD.LDS_APPT_DATE_LOW <> NEW.LDS_APPT_DATE_LOW) THEN
BEGIN
NEW.LDS_APPT_214_DATE = NULL;
END
IF (OLD.LDS_ACT_ARI_DATE IS NULL AND NEW.LDS_ACT_ARI_DATE IS NOT
NULL) THEN
BEGIN
NEW.LDS_ARI_214_DATE = NULL;
END
IF (OLD.LDS_ACT_ARI_DATE <> NEW.LDS_ACT_ARI_DATE) THEN
BEGIN
NEW.LDS_ARI_214_DATE = NULL;
END
IF (OLD.LDS_ACT_BIN_DATE IS NULL AND NEW.LDS_ACT_BIN_DATE IS NOT
NULL) THEN
BEGIN
NEW.LDS_BIN_214_DATE = NULL;
END
IF (OLD.LDS_ACT_BIN_DATE <> NEW.LDS_ACT_BIN_DATE) THEN
BEGIN
NEW.LDS_BIN_214_DATE = NULL;
END
IF (OLD.LDS_ACT_REL_DATE IS NULL AND NEW.LDS_ACT_REL_DATE IS NOT
NULL) THEN
BEGIN
NEW.LDS_REL_214_DATE = NULL;
END
IF (OLD.LDS_ACT_REL_DATE <> NEW.LDS_ACT_REL_DATE) THEN
BEGIN
NEW.LDS_REL_214_DATE = NULL;
END
IF (OLD.LDS_ACT_DEP_DATE IS NULL AND NEW.LDS_ACT_DEP_DATE IS NOT
NULL) THEN
BEGIN
NEW.LDS_DEP_214_DATE = NULL;
END
IF (OLD.LDS_ACT_DEP_DATE <> NEW.LDS_ACT_DEP_DATE) THEN
BEGIN
NEW.LDS_DEP_214_DATE = NULL;
END
END
^
This works perfectly in all FB 1.x versions. Have I found a bug in FB
2 or has something changed that I don't know about?