Skip site navigation (1) Skip section navigation (2)

quote text array

From: Laurent Buffat <laurent(dot)buffat(at)altrabio(dot)com>
To: pgsql-docs(at)postgresql(dot)org
Subject: quote text array
Date: 2008-07-09 17:46:17
Message-ID: 290B018E-D49A-4203-B85A-6D1A2BAADF8B@altrabio.com (view raw or flat)
Thread:
Lists: pgsql-docs
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



pgsql-docs by date

Next:From: James RobinsonDate: 2008-07-11 16:25:35
Subject: plpgsql, declare blocks, and '=' versus ':='
Previous:From: Bruce MomjianDate: 2008-06-26 22:25:24
Subject: Re: Backslash Escape Sequences

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group