The easiest way that I can think of is using plpython (although for those so
inclined, I imagine plperl might do the job about as easily):
create function nelem(text) returns int as '
return len(args[0].split('',''))
' language 'plpython';
That should work very quickly compared with any loop or recursion. The first
call might take a moment to load the python interpreter, but after that if
should be fine.
Regards,
Jeff
On Thursday 12 September 2002 01:50 pm, Douglas Blood wrote:
> I have a field in my database that is comma deliminated values. I know that
> I can count up how many values are there using java but i was wondering if
> there was a way using postgres functions or just standard sql. I was
> thinking a recursive function with substrings and finding the next location
> of the comma but I don't know if it will work or if it does the effect on
> the database. Any help would be great.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org