0
我可和PostgreSQL合作,我想如果存在。我的代码DROP TABLE是PostgreSQL的删除表如果存在
execute 'drop table if exists production.'|| layer_name || '' into result_var;
exception
when others then
execute 'insert into production.'|| layer_name || ' select * from staging.'|| layer_name ;
return 1;
但表如果不存在thows exeption。我不想特罗exeption
有谁能够帮助我?
正如Daniel提到的,“WHEN OTHERS”块隐藏了错误。如果您打算使用这种全面的方法,使用“SQLERRM”或“GET STACKED DIAGNOSTICS”发出错误消息通常会很有帮助。请参阅http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-EXCEPTION-DIAGNOSTICS – bma