需要创建一个存储过程来更新表

时间:2020-03-05 21:31:56

标签: postgresql

发布新记录时,我希望从表A(主表)更新表B。 表数据是相同的,只是转储到表B以保持更多的数据量。

我正在为此编写存储过程,下面是我所拥有的,但是在begin语句中抛出错误

ID列是此处的唯一标识符。 DB是PostgreSQL

create or replace procedure proc 1 ()
as
begin
      INSERT into table B (Col1, Col2, Col3, etc)
             select (Col1, Col2, Col3, etc) from table A
             where not exists (
             select (Col1, Col2, Col3, etc)
             from    table B     
             where table A.id = TableB.id  
end

非常感谢您的帮助。

0 个答案:

没有答案
相关问题