How to use an array string - Mailing list pgsql-sql

From Samuel J. Sutjiono
Subject How to use an array string
Date
Msg-id 010c01c1cf83$c6bb8cd0$110a010a@headquarters.wcgroup.com
Whole thread Raw
List 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

pgsql-sql by date:

Previous
From: Jean-Luc Lachance
Date:
Subject: Re: How to create crude report with psql and/or plpgsql
Next
From: Jean-Luc Lachance
Date:
Subject: Re: [GENERAL] How to create crude report with psql and/or plpgsql