Re: sort a referenced list

From: Jim Nasby <jnasby(at)pervasive(dot)com>
To: Matthew Peter <survivedsushi(at)yahoo(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Merlin Moncure <mmoncure(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: sort a referenced list
Date: 2006-04-06 20:48:37
Message-ID: BF269696-FB8C-4B2A-98E2-B0184965CE61@pervasive.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Apr 4, 2006, at 3:22 PM, Matthew Peter wrote:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote: Matthew Peter writes:
> > What I'm trying to do is create a function that accepts a list
> then sorts and groups the values (like in sql)... I will have an
> unique list I can convert it to an array later or leave it a list
>
> There is no "list" data structure in SQL. There are tables, and there
> are arrays, but it's not especially easy to pass an arbitrary table
> value to a function. So you almost certainly need to define your
> problem as "create a function that accepts an array then ...".
>
> regards, tom lane
>
> Originally I wanted to pass in text or varchar array, group it,
> sort it then do as I willed with it, but I couldn't figure out how.
> I saw some functions in the contrib for doing these operations, yet
> only with integer arrays.
>
> I could always try converting the array_sort, array_uniq int[] C
> function to accept text[], but I decided to ask and see if there
> was a simplier/standard way first since I don't know C all that well.

Sadly there's very little in the way of array operators in
PostgreSQL, so your best bet would be to modify what's in contrib,
preferably allowing it to work with any data type. I'm guessing that
the int array stuff is in contrib and not in the backend because
we're waiting for someone to make it work for all types...
--
Jim C. Nasby, Sr. Engineering Consultant jnasby(at)pervasive(dot)com
Pervasive Software http://pervasive.com work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-04-06 20:50:10 Re: Queries with Regular Expressions
Previous Message Terry Lee Tucker 2006-04-06 20:48:15 Re: plgpsql and transactions