PQexec() with multiple sql statements. - Mailing list pgsql-general

From Yasuo Ohgaki
Subject PQexec() with multiple sql statements.
Date
Msg-id 9aqufd$1us$1@news.tht.net
Whole thread Raw
Responses Re: PQexec() with multiple sql statements.
List pgsql-general
Hello all,

I'm would like to know how PQexec() treats query passed as its parameter.
(PostgreSQL 7.0.3/Linux)

When I pass sql statements like

----------------- BEGIN --------------
CREATE TABLE tmp (
    id serial,
    txt text
);

INSERT INTO tmp (txt) VALUES ('test str');
----------------- END -----------------

INSERT INTO issues an error. "table tmp does not exist" (it is not an exact
message but basically it says so. It works if I pass statement  one by one.)

I've looked PostgreSQL Programmer's Manual, but I couldn't find why PQexec()
does this.
Could anyone explain why PQexec() does not allow INSERT after CREATE TABLE?

If PQexec() makes sure "multiple sql statements query", passed to it, is
executed atomically, I would like to take advantage of it.

Thanks in advance.

PS: I'm not using libpq directly, but from PHP. I believe pg_exec() in PHP is
just a wrapper function of PQexec(), isn't it?

--
Yasuo Ohgaki




pgsql-general by date:

Previous
From: The Hermit Hacker
Date:
Subject: Re: linux/bsd
Next
From: Lincoln Yeoh
Date:
Subject: Re: PQexec() with multiple sql statements.