> 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