Re: How to hand over array as variable in plpgsql function?

From: "Jan Peters" <petersjan(at)gmx(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to hand over array as variable in plpgsql function?
Date: 2008-10-28 08:23:40
Message-ID: 20081028082340.65210@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi Tom (and hello all again),
thanks for your reply.

> Seems like using EXECUTE is the hardest possible way to do this. Why
> don't you just SELECT?
>
> SELECT id FROM precip_arrays WHERE b = precip_control INTO id_result;

How should the code look like to do this? I am using EXECUTE because I don't know how to write the SQL equivalent. How would the SQL code look like if I have these two statements (one returning an array, the other taking this array and compares it to some other arrays in the db):

SELECT precip_control FROM precip_arrays WHERE id = 400; --returns an array
SELECT id FROM precip_arrays WHERE [THE RETURNED ARRAY] = precip_scenario;--compares the above array to the arrays in colum "precip_scenario".

This obviously does NOT work:

SELECT id FROM precip_arrays WHERE (SELECT precip_control FROM precip_arrays WHERE id = 400;) = precip_control;

Is something like the above statement possible?

Sorry for my ignorance and thanks in advance again

Jan

--

Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Nacef LABIDI 2008-10-28 11:14:24 Performing intersection without intersect operator
Previous Message Tom Lane 2008-10-27 19:46:30 Re: How to hand over array as variable in plpgsql function?