Re: ECPG question about PREPARE and EXECUTE

Lists: pgsql-hackers
From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>, Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: ECPG question about PREPARE and EXECUTE
Date: 2010-11-10 10:44:52
Message-ID: 4CDA77A4.3050407@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

a question came to us in the form of a code example,
which I shortened. Say, we have this structure:

============================
EXEC SQL BEGIN DECLARE SECTION;

struct t1 {
int id;
char t[80];
};
typedef struct t1 t1_t;

t1_t t1;
EXEC SQL END DECLARE SECTION;
============================

and a similar table in the database. The client wanted
to use a PREPARE / EXECUTE pair this way:

============================
EXEC SQL PREPARE myquery AS
SELECT * FROM t1 WHERE id = :t1.id;

t1.id = 1;

EXEC SQL EXECUTE myquery INTO :t1;
============================

Upon executing the EXECUTE query, we get an error:

SQL error: too few arguments on line NNN

The problem is that the input parameters given to the
PREPARE are not preserved and carried to the EXECUTE.

Any comment on why it isn't done?

Best regards,
Zoltán Böszörményi

--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
http://www.postgresql.at/


From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
Cc: Michael Meskes <meskes(at)postgresql(dot)org>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>, Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ECPG question about PREPARE and EXECUTE
Date: 2010-11-28 16:33:11
Message-ID: 20101128163311.GA1084@feivel.credativ.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Nov 10, 2010 at 11:44:52AM +0100, Boszormenyi Zoltan wrote:
> a question came to us in the form of a code example,
> which I shortened. Say, we have this structure:
> ...
> Any comment on why it isn't done?

Missing feature. Originally the pure text based statement copying wasn't able
to cope with these and then it simply wasn't implemented when we went to server
side prepares, that is if my memory serves well.

The same feature is implemented for cursor declaration/open I think.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL