Re: references/tutorial/tricks on dynamic generation of sql (& plpgsql functions) editing/coding - Mailing list pgsql-general

From Marcin Mank
Subject Re: references/tutorial/tricks on dynamic generation of sql (& plpgsql functions) editing/coding
Date
Msg-id 057d01c6d5a5$7a6cd230$0c67a8c0@maniek
Whole thread Raw
In response to references/tutorial/tricks on dynamic generation of sql (& plpgsql functions) editing/coding  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
List 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

pgsql-general by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: [ANNOUNCE] == PostgreSQL Weekly News - September 10 2006 ==
Next
From: "Purusothaman A"
Date:
Subject: Re: [ADMIN] Problem with lo_export() and lo_import() from remote machine.