anyrecord/anyelement escaping question. - Mailing list pgsql-general

From Marc Mamin
Subject anyrecord/anyelement escaping question.
Date
Msg-id B6F6FD62F2624C4C9916AC0175D56D8828A3585F@jenmbs01.ad.intershop.net
Whole thread Raw
List pgsql-general
Hello,
 
I'd  like to store  some "special" record of a list of tables in a single table for later reimport:
 
e.g.:
 
table t1 (a int, b int)
table t2 (c int, t varchar)
 
myTable (tsource text   trecord text):
 
t1, (1,2)
t1, (3,18)
t2, (1,'a b')
 
Later I will be able to populate t1 or t2 tables using the content of myTable
something like :
 
EXECUTE 'insert into '||tsource||' values '||trecord FROM myTable.
 
What I'm looking for is a "record escaping" function that would put the single quotes as required later on from a table.
 
e.g. select somefunc(t2) from t2:
 
somefunc
text
-------
1,'a b'
 
 
I could be  happy too with such a function on anyelement:
 
select escape(c)||','||escape(t)  from t2
 
 
 
Is there some built in function I can use for this, or do I have to write it from scratch:
 
create function myescape(a anyelement, OUT escaped text) as $$
 
..
select case when typeof(a) =   then
            when typeof(a) =   then
            when typeof(a) =   then
            when typeof(a) =   then
..
 
 
regards,
 
Marc Mamin
 

pgsql-general by date:

Previous
From: itishree sukla
Date:
Subject: Multi Master Replication
Next
From: Rahila Syed
Date:
Subject: Re: Replication: GZIP compression in WAL sender/receiver processes communication?