Re: anonymous block in Postgres - Hello World - Mailing list pgsql-admin

From Tom Lane
Subject Re: anonymous block in Postgres - Hello World
Date
Msg-id 5493.1180022273@sss.pgh.pa.us
Whole thread Raw
In response to Re: anonymous block in Postgres - Hello World  ("Igor Neyman" <ineyman@perceptron.com>)
List pgsql-admin
"Igor Neyman" <ineyman@perceptron.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

pgsql-admin by date:

Previous
From: Tom Lane
Date:
Subject: Re: Can't drop tables ERROR: cache lookup failed for relation 411727
Next
From: Nicola Mauri
Date:
Subject: Abnormal storage consumption with autovacuum enabled