我必须在存储过程中创建多个表,
create or replace procedure test()
language sql
as $$
drop table if exists a1;
create table a1 as
select * from mastertable;
drop table if exists a2;
create table a2 as
select * from a1 with some filter
drop table if exists a3;
create table a3 as
select * from a2 with some filter
;$$
但它抛出了一个错误
ERROR: relation mastertable" does not exist
LINE 40: from mastertable
请帮我修好它。
1条答案
按热度按时间igetnqfo1#
问题出在第一次选择时,它说可主化关系不存在。您希望在公共模式中创建可主化表,以便能够像这样调用它,或者您应该在表名(可主化)前面添加schema.。这应该可以解决问题,但在创建表a2和a3时,在过滤后还缺少几个分号。