Thread: quote text array

quote text array

From
Laurent Buffat
Date:
Hi,

I would like to know how to allways quote all the string in the result
of a select for a text array ?

Here is some code :

CREATE TABLE textarray ( name text[] );
INSERT INTO textarray VALUES ( '{ab,cd}');
INSERT INTO textarray VALUES ( '{a''b,cd}');
INSERT INTO textarray VALUES ( '{"a,b",cd}');
INSERT INTO textarray VALUES( array['a"b','cd']);
SELECT * FROM textarray;
    name
------------
  {ab,cd}
  {a'b,cd}
  {"a,b",cd}
  {"a\"b",cd}
(4 rows)


For the two last row, the first string is double quote.
Is-it possible to have alway these double quote for all the string the
result ?

like this : (it's a artificial result)

name
------------
  {"ab","cd"}
  {"a'b","cd"}
  {"a,b","cd"}
  {"a\"b","cd"}
(4 rows)

Thanks for your help.

Laurent