vibhuti nataraj writes:
EXECUTE 'CREATE SCHEMA test; CREATE TABLE test.t (id integer ); INSERT INTO
test.t (id) VALUES (0);';
That's not going to work because the whole string is parsed before any of
it is executed. In particular, parse analysis of the INSERT is going to
spit up because neither the table nor even the schema exist yet.
EXECUTE 'CREATE SCHEMA test; CREATE TABLE test.t (id integer );';
EXECUTE 'INSERT INTO test.t (id) VALUES (0);';
The reason this happens to work is that CREATE TABLE is a utility
statement, which doesn't do any parse analysis to speak of, in
particular it doesn't notice at parse time whether the mentioned
schema exists. However, that's an implementation detail that
could change from release to release. By and large, trying to
EXECUTE multiple statements in one query string is something best
avoided, especially if any of them are DDL.

    regards, tom lane

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
grouppgsql-general @
categoriespostgresql
postedAug 29, '13 at 9:59p
activeAug 30, '13 at 5:47p
posts2
users2
websitepostgresql.org
irc#postgresql

2 users in discussion

Tom Lane: 1 post Vibhuti nataraj: 1 post

People

Translate

site design / logo © 2017 Grokbase