From: | Igor Neyman <ineyman(at)perceptron(dot)com> |
---|---|
To: | Michael Moore <michaeljmoore(at)gmail(dot)com>, postgres list <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: cvs text to quoted cvs text |
Date: | 2016-09-26 19:28:09 |
Message-ID: | MWHPR07MB287790BD15741D4336AD1A65DACD0@MWHPR07MB2877.namprd07.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Regards,
Igor
From: pgsql-sql-owner(at)postgresql(dot)org [mailto:pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of Michael Moore
Sent: Monday, September 26, 2016 3:23 PM
To: postgres list <pgsql-sql(at)postgresql(dot)org>
Subject: [SQL] cvs text to quoted cvs text
I have some input parameters on a function that will by use in dynamic sql as part of an IN list. For example:
'select val from mytab where zzz in ('||csv_input_parm::text||')';
The problem is that csv_input_parm is formatted like:
[THIS,THAT,THE OTHER] while the IN list would need
['THIS','THAT','THE OTHER'] brackets not included.
I came up with this approach to do the conversion:
select ''''||array_to_string(string_to_array('THIS,THAT,THE OTHER',','),''',''')||'''' rslt
It gets the job done, but it's ugly. Is there a way that is not ugly?
thanks,
Mike
Take a look at quote_literal(…) function.
Regards,
Igor Neyman
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2016-09-26 19:33:22 | Re: cvs text to quoted cvs text |
Previous Message | Michael Moore | 2016-09-26 19:23:25 | cvs text to quoted cvs text |