Re: references/tutorial/tricks on dynamic generation of sql (& plpgsql functions) editing/coding

From: "Marcin Mank" <marcin(dot)mank(at)gmail(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: references/tutorial/tricks on dynamic generation of sql (& plpgsql functions) editing/coding
Date: 2006-09-11 13:23:30
Message-ID: 057d01c6d5a5$7a6cd230$0c67a8c0@maniek
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I'm using pg 7.4 so $$ trick shouldn't work.
Should work. if you put enugh $$, somebody might backport this for you ;)

how about:

create or replace function SP_GarbageCollectionGenerate()
returns bool as '
declare
v_query text;
begin
v_qyery=''create or replace blah blah
:para1 blah blah
blah blah :para2
'';
v_query=replace(v_query,'':para1'',quote_literal(value_1));
v_query=replace(v_query,'':para2'',quote_ident(value_2));
execute v_query;

end;
' language plpgsql;

a bit more readable, I think.

Greetings
Marcin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Purusothaman A 2006-09-11 13:30:00 Re: [GENERAL] Problem with lo_export() and lo_import() from remote machine.
Previous Message Tatsuo Ishii 2006-09-11 12:59:20 Re: [ANNOUNCE] == PostgreSQL Weekly News - September 10 2006 ==