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