【发布时间】:2017-10-09 08:12:49
【问题描述】:
我想为创建表或选择创建事件触发器, 例如: 创建表 xxxx 时,表名必须以 'temp' 变大
我的代码
CREATE OR REPLACE FUNCTION create_table_func()
RETURNS event_trigger
AS
$$
DECLARE
V_TABLE name := TG_TABLE_NAME;
BEGIN
if V_TABLE !~ '^temp'
then
RAISE EXCEPTION 'must bigen with temp';
end if;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
CREATE EVENT TRIGGER create_table_1 ON ddl_command_start
WHEN TAG IN ('SELECT INTO')
EXECUTE PROCEDURE create_table_func();
但是当执行时 select * into test11 from test_bak
[Err] 错误:列“tg_table_name”不存在
【问题讨论】: