pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Milen Kulev <makulev@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Prepared statements in PGSQL functions
Date: Wed, 14 Jun 2006 10:35:28 -0400
Message-ID: <23768.1150295728@sss.pgh.pa.us> (raw)
In-Reply-To: <010a01c68fb4$34db9990$0a00a8c0@trivadis.com>
References: <010a01c68fb4$34db9990$0a00a8c0@trivadis.com>

"Milen Kulev" <makulev@gmx.net> 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



view thread (4+ messages)  latest in thread

Message-ID: <23768.1150295728@sss.pgh.pa.us>
Permalink:  ../23768.1150295728@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23768.1150295728@sss.pgh.pa.us

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, makulev@gmx.net
  Subject: Re: Prepared statements in PGSQL functions
  In-Reply-To: <23768.1150295728@sss.pgh.pa.us>

* 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