I initialized two arrays in a function, one for numbers (list of amounts) and the other for text (list of invoices). I want to call another function from this one and pass these two arrays as parameters.
I can call the function this way and everything is OK:
select function_2('{110011-0115-7}'::text[], '{100}'::numeric[])
But when I want send a variable that holds a text array the array seems to be empty:
select function_2(ARRAY[invoice_list], ARRAY[amount_list]);
Function definition:
CREATE OR REPLACE FUNCTION function_1(OUT out_code1 integer
, OUT out_message1 text)
RETURNS RECORD AS
$BODY$
DECLARE
counter numeric;
inv_cur record;
invoice_list text[];
amount_list numeric[];
BEGIN
FOR inv_cur IN
SELECT "ID", "AMOUNT"
FROM "INVOICE"
WHERE "ACCOUNT_ID" = in_account
LOOP
--Adding invoices to invoice array
invoice_list[counter] := inv_cur."ID";
--Adding amounts to amount array
amount_list[counter] := inv_cur."AMOUNT";
--Increasing counter for array indexes
counter := counter + 1;
END LOOP;
--Caling other function
SELECT * FROM function_2(ARRAY[invoice_list], ARRAY[amount_list]);
END
$BODY$
LANGUAGE plpgsql VOLATILE
Other function definition:
CREATE OR REPLACE FUNCTION function_2(in_invoices text[]
, in_amounts numeric[]) ...