Search Postgresql Archives

anyrecord/anyelement escaping question.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
 

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux