From: Samuel J. Sutjiono <ssutjiono@wc-group.com>
To: pgsql-general@postgresql.org
To: pgsql-sql@postgresql.org
Subject: How to use an array string
Date: Tue, 19 Mar 2002 15:22:21 -0500
Message-ID: <010c01c1cf83$c6bb8cd0$110a010a@headquarters.wcgroup.com> (raw)
Hi All,
I need help. I want to build a list of customers (custid) that has the word 'sam' in their fullname and store them to a text string (ResultList). Then on the second query, I want to select the customers with ID that matches the ID in the ResultList.
DECLARE
rec_set record;
s_result text;
ResultList text := '''';
BEGIN
For rec_set IN SELECT CustID
FROM Customer where Fullname ~* ''(sam)''
LOOP
ResultList := ResultList || '''''''' || rec_set.CustID || '''''''' || '', '';
END LOOP;
END;
BEGIN
For rec_set IN SELECT Fullname, Address
/*from Customer where CustID in (''1220'', ''3452'', ''4112'', '''')*/
from Customer where CustID in (ResultList)
END;
The problem is that the query can't find any match. Maybe because it compares a CustID with a string of values (ResultList). Does anybody have any suggestions on how I can get around this ? Does anybody know how to build an array string so I can store the cust id ?
Thanks,
Sam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ssutjiono@wc-group.com, pgsql-general@postgresql.org
Subject: Re: How to use an array string
In-Reply-To: <010c01c1cf83$c6bb8cd0$110a010a@headquarters.wcgroup.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox