I am trying to loop over a 2D array getting the first and second value from each row to update a table
CREATE OR REPLACE FUNCTION fc_update_arrangement(input_arrangementid int, input_NAME text, input_price money, input_expirationdate date, products int[][])
RETURNS void AS
$BODY$
BEGIN
UPDATE arrangement SET "NAME" = $2, price = $3, expirationdate = $4 WHERE arrangementid = $1;
-- loop through array getting the first and second value
-- UPDATE productinarrangement SET amount = arrayinputnumber2 WHERE productid = arrayinputnumber1 AND arrangementid = $1
END;
$BODY$ LANGUAGE plpgsql STRICT;
With help I got the function call right, which doesn't return errors anymore. I don't understand how I can loop through the array getting the values within? I've commented out the lines and I don't know what to do. I call the function within this line:
SELECT fc_update_arrangement(1::int,'tom'::text,15::money,now()::date,array[array[1,2],array[3,4]]);