X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 77EBC9FA5D8 for ; Wed, 14 Jun 2006 11:35:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 24926-01 for ; Wed, 14 Jun 2006 11:35:32 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 27CA39F9CAA for ; Wed, 14 Jun 2006 11:35:31 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k5EEZS6B023769; Wed, 14 Jun 2006 10:35:28 -0400 (EDT) To: "Milen Kulev" cc: pgsql-sql@postgresql.org Subject: Re: Prepared statements in PGSQL functions In-reply-to: <010a01c68fb4$34db9990$0a00a8c0@trivadis.com> References: <010a01c68fb4$34db9990$0a00a8c0@trivadis.com> Comments: In-reply-to "Milen Kulev" message dated "Wed, 14 Jun 2006 15:12:36 +0200" Date: Wed, 14 Jun 2006 10:35:28 -0400 Message-ID: <23768.1150295728@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/158 X-Sequence-Number: 25394 "Milen Kulev" writes: > I want to use prepared statement in a function. Why? You seem not to be aware that plpgsql implicitly prepares statements behind the scenes. > prepare mystmt( int, int, varchar) as insert into part values ($1,$2,$3); > execute mystmt(v_id1, v_id2, v_filler ); > deallocate mystmt; If that worked it would be *exactly* the same as just doing insert into part values (v_id1, v_id2, v_filler); except for being slower due to re-preparing each time through the function. So don't waste your time trying to outsmart the language. regards, tom lane