How to hand over array as variable in plpgsql function?

From: "Jan Peters" <petersjan(at)gmx(dot)at>
To: pgsql-sql(at)postgresql(dot)org
Subject: How to hand over array as variable in plpgsql function?
Date: 2008-10-27 16:25:37
Message-ID: 20081027162537.66060@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dear list,
I am trying to hand over an float4 array of a previous query in my plpgsql function. The query returns the correct array but when I try to hand over this array to another function I get the error message:

ERROR: operator is not unique: "unknown" || real[]
SQL state: 42725
Hint: Could not choose a best candidate operator. You may need to add explicit type casts.
Context: PL/pgSQL function "get_matching_ids_sql_id" line 19 at execute statement. The function looks like this:

DECLARE
id_result integer;
b float4[];
BEGIN
EXECUTE 'SELECT precip_control FROM precip_arrays WHERE id = 400' INTO b;
[...]
EXECUTE 'SELECT id FROM precip_arrays WHERE '||b||' = precip_control;' INTO id_result;
RETURN id_result ;
END;

I know that there is a problem with the " '||b||' " part, so could someone point me in the right direction how to right this statement correctly, so that the array can be processed by this SQL statement?

Thanks in advance and kind regards

Jan Peters-Anders

--
"Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Osvaldo Kussama 2008-10-27 19:28:09 Fwd: grouping/clustering query
Previous Message Tom Lane 2008-10-27 12:15:20 Re: SQL Statement Missing From Log