Re: postgres functions

From: Jeff Davis <list-pgsql-general(at)empires(dot)org>
To: "Douglas Blood" <dblood(at)matraex(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: postgres functions
Date: 2002-09-13 22:20:38
Message-ID: 200209131520.38391.list-pgsql-general@empires.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


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(at)postgresql(dot)org

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2002-09-13 22:24:12 Re: cascading
Previous Message Jeff Davis 2002-09-13 22:03:38 Re: Panic - Format has changed