Received: from mail.ngi.de ([195.243.0.227]) by hub.org (8.9.3/8.9.3) with ESMTP id IAA00718 for ; Thu, 2 Dec 1999 08:04:33 -0500 (EST) (envelope-from michael@fam-meskes.de) Received: from p3E9D3E10.dip0.t-ipconnect.de (root@p3E9D3E10.dip0.t-ipconnect.de [62.157.62.16]) by mail.ngi.de (8.9.3/8.9.3) with ESMTP id NAA93016; Thu, 2 Dec 1999 13:56:15 +0100 (CET) (envelope-from michael@fam-meskes.de) Received: (from michael@localhost) by tanja.fam-meskes.de (8.9.3/8.9.3/Debian 8.9.3-6) id OAA02323; Thu, 2 Dec 1999 14:05:05 +0100 Date: Thu, 2 Dec 1999 14:05:05 +0100 From: Michael Meskes To: "UEBAYASHI 'UMA' Masao" Cc: pgsql-interfaces@postgresql.org Subject: Re: [INTERFACES] ecpg: why use PREPARE? Message-ID: <19991202140505.A2305@fam-meskes.de> Mail-Followup-To: UEBAYASHI 'UMA' Masao , pgsql-interfaces@postgresql.org References: <19991202191428J.masao@nf.enveng.titech.ac.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii User-Agent: Mutt/1.0i In-Reply-To: <19991202191428J.masao@nf.enveng.titech.ac.jp>; from masao@nf.enveng.titech.ac.jp on Thu, Dec 02, 1999 at 07:14:28PM +0900 On Thu, Dec 02, 1999 at 07:14:28PM +0900, UEBAYASHI 'UMA' Masao wrote: > example programs. I can see such lines like below in test2.pgc: > ... > As far, I know the differences between the normal one and the parepare As the comment says: /* and now the same query with prepare */ This example is just to check ecpg's functionality and to show that it is possible to use prepare. > 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. That's what supposed to happen. PREPARE is used for so-called dynamic SQL. Just imagine a query where a variable in the where clause changes depending on the flow of a program. Then you can either use two different cursors with quite some work needed doubling program logic or you used give the prepared statement the other variable via the using clause. Or thing about an SQL statement that is dynamically created during run time. You cannot use this without preparing it. Hope this helps. Michael -- Michael Meskes | Go SF 49ers! Th.-Heuss-Str. 61, D-41812 Erkelenz | Go Rhein Fire! Tel.: (+49) 2431/72651 | Use Debian GNU/Linux! Email: Michael@Fam-Meskes.De | Use PostgreSQL!