From: | David Gagnon <dgagnon(at)siunik(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | how to convert a string array to a string. fct array_to_string seem to work only for INT array?? |
Date: | 2007-05-10 11:07:47 |
Message-ID: | 4642FD03.6030106@siunik.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi all,
I'm messing with this, I think simple, problem. I searched the doc
and the web without success .. hum
I have a string array(Compte[]) and I need to create the following
string statement to populate a temporary table
statement := ' INSERT INTO T_CR1 ( CRNUM, CRMONT, CSGLNUM, CRDATE)
SELECT CRNUM, CSGLNUM, CRMONT, CRDATE
FROM CR INNER JOIN CS ON CR.CRNUM = CS.CSCRNUM AND
CR.CRYPNUM = CS.CSYPNUM
WHERE CRYPNUM = ' || quote_literal(companyId) || '
AND CRDATE <= CURRENT_DATE
AND CSGLNUM IN {' || array_to_string(Compte, ',') || '}';
EXECUTE statement;
For now I get :
INSERT INTO T_CR1 ( CRNUM, CRMONT, CSGLNUM, CRDATE)
SELECT CRNUM, CSGLNUM, CRMONT, CRDATE
FROM CR INNER JOIN CS ON CR.CRNUM = CS.CSCRNUM AND
CR.CRYPNUM = CS.CSYPNUM
WHERE CRYPNUM = 'M'
AND CRDATE <= CURRENT_DATE
AND CSGLNUM IN {cpt1, cpt2}
But I want:
INSERT INTO T_CR1 ( CRNUM, CRMONT, CSGLNUM, CRDATE)
SELECT CRNUM, CSGLNUM, CRMONT, CRDATE
FROM CR INNER JOIN CS ON CR.CRNUM = CS.CSCRNUM AND
CR.CRYPNUM = CS.CSYPNUM
WHERE CRYPNUM = 'M'
AND CRDATE <= CURRENT_DATE
AND CSGLNUM IN {'cpt1', 'cpt2'}
How can I do that. I expected to find a standard function in the doc to
do that ...
Thanks for your help!
Best Regards
David
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Strube | 2007-05-10 11:14:27 | Invoke trigger after commit |
Previous Message | Dawid Kuroczko | 2007-05-10 07:16:21 | Re: Dangers of fsync = off |