Re: How to hand over array as variable in plpgsql function? - Mailing list pgsql-sql

From Jan Peters
Subject Re: How to hand over array as variable in plpgsql function?
Date
Msg-id 20081028082340.65210@gmx.net
Whole thread Raw
In response to Re: How to hand over array as variable in plpgsql function?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: How to hand over array as variable in plpgsql function?
List 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
wouldthe SQL code look like if I have these two statements (one returning an array, the other taking this array and
comparesit 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


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: How to hand over array as variable in plpgsql function?
Next
From: "Nacef LABIDI"
Date:
Subject: Performing intersection without intersect operator