Re: Newbie, Howto access Array-Slots in user defined functions?

From: "Len Morgan" <len-morgan(at)crcom(dot)net>
To: "PGSQL Mailinglist" <pgsql-general(at)hub(dot)org>, "Martin Jacobs" <100(dot)179370(at)germanynet(dot)de>
Subject: Re: Newbie, Howto access Array-Slots in user defined functions?
Date: 2000-10-06 00:30:40
Message-ID: 005d01c02f2c$a9528d40$0908a8c0@H233.bstx.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
> SELECT DISTINCT c FROM table;
>
>I get
>
>ERROR: There is no operator '<' for types '_bytea' and '_bytea'
> You will either have to retype this query using an explicit cast,
> or you will have to define the operator using CREATE OPERATOR
>
>To create an operator I need a function, so let's beginn with a
>compare function:
>
> CREATE FUNCTION lessbyte (_bytea, _bytea) RETURNS bool AS
> 'SELECT $1[1] < $[2];' LANGUAGE 'sql';

Shouldn't the above be:
SELECT $1[1] < $1[2] ?

You probably need the field reference in both places. I have never used
arrays so I don't know if I'm way off base but it seems logical.

Len Morgan

>
>I get
>
> ERROR: parser: parse error at or near "["
>
>Any hint, how to overcome this?
>
>Martin
>
>--
>Martin Jacobs * Windsbach * 100(dot)179370(at)germanynet(dot)de und
>martin(dot)jacobs(at)an-netz(dot)de
>Registered Linux User #87175
>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Davis 2000-10-06 03:20:16 OID use
Previous Message David Huttleston Jr 2000-10-05 23:30:56 Re: Using Microsoft Access as front end to Postgres