Re: Prepared statements in PGSQL functions

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Prepared statements in PGSQL functions
Date: 2006-06-14 13:30:43
Message-ID: 20060614133043.GE23895@webserv.wug-glas.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

am 14.06.2006, um 15:12:36 +0200 mailte Milen Kulev folgendes:
> How to solve my problem ? Is it possible at all to call prepared statement inside a function at all?

Yes, i have a example:

create or replace function foo() returns text as $$
declare sql text;
begin
sql := 'prepare bla(int) as select now();';
execute sql;
sql := 'execute bla(1);';
execute sql;
return 'ready';
end
$$ language plpgsql;

test=*# select foo();
foo
-------
ready
(1 row)

You should execute strings in plpgsql, not prepared statements.

HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47215, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===

In response to

Browse pgsql-sql by date

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