我有一张桌子' chat_record'其中有一列' chat_id'。对于每个聊天内容'存在同名表。现在我想创建一个触发器,以便在删除chat_record的条目时删除该表。 这是我的代码 - **
create trigger drop_table before delete on chat_record
for each row
begin
declare chatid varchar(20);
set @chatid=(select chat_id from chat_record where chat_id=old.chat_id);
drop table chatid;
end;
** 错误1422:不允许显式或隐式提交存储函数或触发器。
答案 0 :(得分:0)
create or replace trigger drop_table1 before delete on chat_record
for each row
declare
chatid1 varchar(20);
pragma autonomous_transaction;
begin
select 1 into chatid1 from chat_record where chat_id=:old.chat_id;
if chatid1 = 1
then
EXECUTE IMMEDIATE 'drop table chatid';
end if;
end;