From: | Marc Mamin <M(dot)Mamin(at)intershop(dot)de> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | anyrecord/anyelement escaping question. |
Date: | 2013-12-18 15:02:52 |
Message-ID: | B6F6FD62F2624C4C9916AC0175D56D8828A3585F@jenmbs01.ad.intershop.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Dean Gibson (DB Administrator) | 2013-12-18 18:02:04 | Foreign keys |
Previous Message | itishree sukla | 2013-12-18 09:31:44 | Multi Master Replication |