How to use an array string

Поиск
Список
Период
Сортировка
От Samuel J. Sutjiono
Тема How to use an array string
Дата
Msg-id 010c01c1cf83$c6bb8cd0$110a010a@headquarters.wcgroup.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Jean-Luc Lachance
Дата:
Сообщение: Re: How to create crude report with psql and/or plpgsql
Следующее
От: Jean-Luc Lachance
Дата:
Сообщение: Re: [GENERAL] How to create crude report with psql and/or plpgsql