PQexec() with multiple sql statements.

From: "Yasuo Ohgaki" <yasuo_ohgaki(at)hotmial(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: PQexec() with multiple sql statements.
Date: 2001-04-09 00:07:06
Message-ID: 9aqufd$1us$1@news.tht.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Brett W. McCoy 2001-04-09 00:54:26 Re: linux/bsd
Previous Message Tim Freund 2001-04-08 23:11:26 Re: JDBC