Re: Prepared statements in PGSQL functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Milen Kulev" <makulev(at)gmx(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Prepared statements in PGSQL functions
Date: 2006-06-14 14:35:28
Message-ID: 23768.1150295728@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Milen Kulev" <makulev(at)gmx(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Milen Kulev 2006-06-14 15:16:39 Re: Prepared statements in PGSQL functions
Previous Message Aaron Bono 2006-06-14 13:54:08 Re: how to replace 0xe28093 char with another one?