visibility rule in a EXECUTE with multi sql

Started by laserabout 18 years ago2 messagesgeneral
Jump to latest
#1laser
laserlist@pgsqldb.com

hi all,

when I do a:

execute 'set search_path to bar; create table foo(f1 int);insert into
table foo blah..blah;'

in plpgsql, I found that the insert statement always report that "can't
found table foo" or something
like that. I guess it's visibility rule in PostgreSQL, but I can't found
clear docs, can someone
give me some hint about that?

thanks and best regards

laser

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: laser (#1)
Re: visibility rule in a EXECUTE with multi sql

laser <laserlist@pgsqldb.com> writes:

when I do a:

execute 'set search_path to bar; create table foo(f1 int);insert into
table foo blah..blah;'

in plpgsql, I found that the insert statement always report that "can't
found table foo" or something
like that.

Well, yeah. The whole string is parsed, then executed, so you are
trying to parse the insert before foo exists. Break it into multiple
EXECUTEs. Or maybe you want "create table as select ...".

regards, tom lane