ecpg: why use PREPARE?

From: "UEBAYASHI 'UMA' Masao" <masao(at)nf(dot)enveng(dot)titech(dot)ac(dot)jp>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: ecpg: why use PREPARE?
Date: 1999-12-02 10:14:28
Message-ID: 19991202191428J.masao@nf.enveng.titech.ac.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

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

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Jeroen Schellart 1999-12-02 11:20:17 ODBC error message
Previous Message Christian Ullrich 1999-12-02 09:09:27 6.5.3 and ODBC: How to get hold of errors