Re: Prepared statements in PGSQL functions - Mailing list pgsql-sql

From Tom Lane
Subject Re: Prepared statements in PGSQL functions
Date
Msg-id 23768.1150295728@sss.pgh.pa.us
Whole thread Raw
In response to Prepared statements in PGSQL functions  ("Milen Kulev" <makulev@gmx.net>)
Responses Re: Prepared statements in PGSQL functions
List pgsql-sql
"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


pgsql-sql by date:

Previous
From: "Aaron Bono"
Date:
Subject: Re: how to replace 0xe28093 char with another one?
Next
From: "Milen Kulev"
Date:
Subject: Re: Prepared statements in PGSQL functions