Received: from nf.enveng.titech.ac.jp (nf.enveng.titech.ac.jp [131.112.148.3]) by hub.org (8.9.3/8.9.3) with ESMTP id FAA78662 for ; Thu, 2 Dec 1999 05:10:17 -0500 (EST) (envelope-from masao@nf.enveng.titech.ac.jp) Received: from localhost (neon.enveng.titech.ac.jp [131.112.148.211]) by nf.enveng.titech.ac.jp (8.8.7/8.8.7) with ESMTP id TAA03371 for ; Thu, 2 Dec 1999 19:05:12 +0900 (JST) (envelope-from masao@nf.enveng.titech.ac.jp) To: pgsql-interfaces@postgresql.org Subject: ecpg: why use PREPARE? X-Mailer: Mew version 1.94.1 on Emacs 20.4 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <19991202191428J.masao@nf.enveng.titech.ac.jp> Date: Thu, 02 Dec 1999 19:14:28 +0900 From: "UEBAYASHI 'UMA' Masao" X-Dispatcher: imput version 990905(IM130) Lines: 38 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