Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-admin by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group