[Phpwm] plpgsql output array

alan dunn alan at dunns.co.uk
Tue Apr 12 13:22:29 UTC 2011


I wonder if anyone can give me a steer on this - I want to create a 
function in plpgsql which will output a three dimensional array from two 
integer inputs. No matter what I have tried I get the error message: - 
'cannot determine result datatype' , 'a function returning "anyarray" or 
"anyelement" must have at least one arguement of either type'

I admit I am not at all familiar with coding functions as my code 
attempt probably shows. I have tried rtfm - it really didn't help.

Thanks in advance,
alan dunn

Here is my code attempt:

CREATE FUNCTION webprice(IN "EVENTID" integer, IN "WEBIB" integer) 
RETURNS anyarray AS
$BODY$

DECLARE

EVENTID ALIAS FOR $1;
WEBID ALIAS FOR $2;

OUTARR  integer[];

WEBPRICE numeric(7,2) := 0;
WEBPANDP numeric(7,2) := 0;
EVSHOW character(1);


BEGIN
SELECT INTO WEBPRICE, WEBPANDP, EVSHOW web_price, web_pandp, ev_show 
FROM tblwebprice WHERE ev_id = EVENTID AND web_id = WEBID;

OUTARR[1] := WEBPRICE;
OUTARR[2] := WEBPANDP;
OUTARR[3] := EVSHOW;

RETURN OUTARR;

END;

$BODY$
LANGUAGE 'plpgsql' VOLATILE;



More information about the Phpwm mailing list