Re: anonymous block in Postgres - Hello World

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Igor Neyman" <ineyman(at)perceptron(dot)com>
Cc: "Abraham, Danny" <danny_abraham(at)bmc(dot)com>, pgsql-admin(at)postgresql(dot)org, Devrim GÜNDÜZ <devrim(at)gunduz(dot)org>
Subject: Re: anonymous block in Postgres - Hello World
Date: 2007-05-24 15:57:53
Message-ID: 5493.1180022273@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

"Igor Neyman" <ineyman(at)perceptron(dot)com> writes:
> CREATE OR REPLACE FUNCTION exec_plpgsql_block(exec_string text)
> RETURNS BOOLEAN
> AS $THIS$
> DECLARE lRet BOOLEAN;
> BEGIN
> EXECUTE 'CREATE OR REPLACE FUNCTION any_block()
> RETURNS VOID
> AS $$ ' || exec_string || ' $$LANGUAGE PLPGSQL;' ;
> PERFORM any_block();
> RETURN TRUE;
> END;
> $THIS$LANGUAGE PLPGSQL;

That hasn't failed for you yet? It will the first time you use $$
in the argument.

Use quote_literal() please ...

regards, tom lane

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Thomas Mack 2007-05-24 16:16:30 Re: Role based database access
Previous Message Nicola Mauri 2007-05-24 15:56:10 Abnormal storage consumption with autovacuum enabled