From: | Sergio Basurto <sbasurto(at)soft-gator(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | regexp_matches question |
Date: | 2012-09-05 01:39:06 |
Message-ID: | 1346809147.14735.6.camel@basbox |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I am using regexp_matches in a function like this
create or replace function test (v_string in text) returns varchar
as $$
declare
i_strings text[];
i_string text[];
i_strings := regexp_matches(v_string,E'[a-zA-Z0-9:\\s\\-\\.#%
]*:[A-Za-z0-9\\s\\-\\.#%]+','g');
-- Then I use the results
foreach i_string slice 1 in array i_strings
loop
raise notice 'row = %',i_string;
end loop;
when I run the function like this:
select test('1:Warehouse1;2:Warehouse2;');
postgresql complains:
ERROR: query "SELECT regexp_matches(v_string,E'[a-zA-Z0-9:\\s\\-\\.#%
]*:[A-Za-z0-9\\s\\-\\.#%]+','g')" returned more than one row
Why postgres is sending the ERROR?
Off course I am expecting more than one row!, that's why is in a foreach
loop in the first place.
If I run:
select regexp_matches('1:Warehouse1;2:Warehouse2;',E'[a-zA-Z0-9:\\s\\-\
\.#%]*:[A-Za-z0-9\\s\\-\\.#%]+','g');
regexp_matches
----------------
{1:Warehouse1}
{2:Warehouse2}
(2 rows)
I am doing something wrong?
Regards,
From | Date | Subject | |
---|---|---|---|
Next Message | David Johnston | 2012-09-05 01:58:40 | Re: regexp_matches question |
Previous Message | Aleksey Tsalolikhin | 2012-09-05 01:21:55 | postgres process got stuck in "notify interrupt waiting" status |