From: | "Samuel J(dot) Sutjiono" <ssutjiono(at)wc-group(dot)com> |
---|---|
To: | <pgsql-general(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org> |
Subject: | How to use an array string |
Date: | 2002-03-19 20:22:21 |
Message-ID: | 010c01c1cf83$c6bb8cd0$110a010a@headquarters.wcgroup.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Moritz Sinn | 2002-03-19 20:33:06 | anonymous user |
Previous Message | Peter Darley | 2002-03-19 20:15:32 | Building Perl DBI::pg |
From | Date | Subject | |
---|---|---|---|
Next Message | Jean-Luc Lachance | 2002-03-19 20:45:30 | Re: [SQL] How to create crude report with psql and/or plpgsql |
Previous Message | Jean-Luc Lachance | 2002-03-19 19:42:52 | Re: [SQL] How to create crude report with psql and/or plpgsql |