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