当我们开始将我们的应用程序从使用 Oracle 迁移到 PostgreSQL 时,我们遇到了以下问题:
我们的许多 Oracle 脚本创建了适用于 PostgreSQL 中不存在的 Oracle 特定表的触发器。在 PG 数据库上运行这些脚本时,它们不会抛出错误。只有当触发器被触发时,才会引发错误。
示例代码:
-- Invalid query under PostgreSQL
select * from v$mystat;
-- Create a view with the invalid query does not work (as expected)
create or replace view Invalid_View as
select * from v$mystat;
-- Create a test table
create table aaa_test_table (test timestamp);
-- Create a trigger with the invalid query does(!) work (not as expected)
create or replace trigger Invalid_Trigger
before insert
on aaa_test_table
begin
select * from v$mystat;
end;
-- Insert fails if the trigger exists
insert into aaa_test_table (test) values(sysdate);
-- Select from the test table
select * from aaa_test_table
order by test desc;
有没有办法改变这种行为以在触发器创建时引发错误?
亲切的问候, Hammerfels
编辑:
我被告知,我们实际上不使用基本的 PostgreSQL,而是使用 EDB。这可能可以解释为什么 create trigger 的语法似乎是错误的。我很抱歉造成混乱。