Consider following script:
set list on;
set echo on;
set autoddl ON;
shell if exist r:\temp\tmp4test.fdb del r:\temp\tmp4test.fdb;
create database 'localhost:r:\temp\tmp4test.fdb' user 'sysdba' password 'masterkey';
create or alter procedure sp_test(a_x int) as begin end;
recreate table test(id int primary key, x bigint, y bigint);
insert into test values(1, 3, 7);
commit;
set term ^;
create or alter procedure sp_test returns(o_y int) as
begin
suspend;
end
^
commit
^
create or alter trigger test_ad for test active after delete as
begin
-- SQLSTATE = 42S22 / ... / -Column unknown / -NEW.X
-- execute procedure sp_test returning_values(new.x);
-- new.x = 1;
-- SQLSTATE = 42000 /attempted update of read-only column TEST.Y
--execute procedure sp_test returning_values(old.y);
old.y = 2;
end
^
set term ;^
commit;
set count on;
select * from rdb$triggers where rdb$system_flag is distinct from 1;
commit;
delete from test where id = 1; ---------- [ 1 ]
commit;
delete from test where id = 1; ---------- [ 2 ]
commit;
connect 'localhost:r:\temp\tmp4test.fdb' user 'sysdba' password 'masterkey';
delete from test where id = 1; ---------- [ 3 ]
commit;
select * from test;
Compilation of trigger will fail with SQLSTATE = 42000 /attempted update of read-only column TEST.Y, trigger will not be stored in DB.
But statements marked as [1] and [2] will fail with:
Statement failed, SQLSTATE = 42000
attempted update of read-only column
Only statement [3] (which runs after re-connect) will complete w/o error.
If we change trigger in such manner:
-- SQLSTATE = 42S22 / ... / -Column unknown / -NEW.X
-- execute procedure sp_test returning_values(new.x);
new.x = 1;
-- SQLSTATE = 42000 /attempted update of read-only column TEST.Y
--execute procedure sp_test returning_values(old.y);
-- old.y = 2;
-- then no problems with DML statements, they run w/o errors.
Checked on WI-V3.0.14.33855; WI-V4.0.7.3269; WI-V5.0.4.1808.
Consider following script:
Compilation of trigger will fail with
SQLSTATE = 42000 /attempted update of read-only column TEST.Y, trigger will not be stored in DB.But statements marked as
[1]and[2]will fail with:Only statement
[3](which runs after re-connect) will complete w/o error.If we change trigger in such manner:
-- then no problems with DML statements, they run w/o errors.
Checked on WI-V3.0.14.33855; WI-V4.0.7.3269; WI-V5.0.4.1808.