From: UEBAYASHI 'UMA' Masao <masao@nf.enveng.titech.ac.jp>
To: pgsql-interfaces@postgresql.org
Subject: ecpg: why use PREPARE?
Date: Thu, 02 Dec 1999 19:14:28 +0900
Message-ID: <19991202191428J.masao@nf.enveng.titech.ac.jp> (raw)
I'm new to both PostgreSQL and ecpg (Embedded SQL), and examinig ecpg
example programs. I can see such lines like below in test2.pgc:
| ...
| /* normal version */
| exec sql open cur;
| exec sql whenever not found do break;
| while (1) {
| exec sql fetch in cur into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
| ...
| }
| exec sql close cur;
| ...
| ...
| /* prepare version */
| exec sql prepare MM from :query;
| exec sql declare prep cursor for MM;
| exec sql open prep using :testname;
| exec sql whenever not found do break;
| while (1) {
| exec sql fetch in prep into :personal:ind_personal, :married:ind_married, :children.integer:ind_children.smallint;
| ...
| }
| ...
As far, I know the differences between the normal one and the parepare
one are that the prepare one:
1) prepares statement `MM' and creates cursor on it.
2) opens the cursor with ``using''
I have no idea what these mean. My test program which is simply
changed from ``declare cursor'' to ``prepare + declare'' seems to run
the same way and takes the same time.
Any help will be appreciated. :)
Masao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-interfaces@postgresql.org
Cc: masao@nf.enveng.titech.ac.jp
Subject: Re: ecpg: why use PREPARE?
In-Reply-To: <19991202191428J.masao@nf.enveng.titech.ac.jp>
References: <19991202191428J.masao@nf.enveng.titech.ac.jp>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox