DB2 v10.5.0.1, special_31160, IP23526_31160 and Fix Pack 1
Product name: "DB2 Express-C"
License type: "Unwarranted"
Expiry date: "Permanent"
Product identifier: "db2expc"
Version information: "10.5"
Max number of CPUs: "2"
Max amount of memory (GB): "16"
Enforcement policy: "Soft Stop"

-----------------------------------------------------------------------------------
I have this function to create a matrix(row, col) filled with 0 working on Postgre and Oracle, but i don't know how to use matrix in db2 and don't find any example. Is possible use matrix type?

POSTGRE

CREATE OR REPLACE FUNCTION new_Matriz(integer,integer)
RETURNS integer[][] AS
$$
DECLARE
rown integer := $1;
cols integer := $2;
value integer := 0;
i integer;
v_array integer[] := array(SELECT value from generate_series(1,cols));
v_matriz integer[][] := array[v_array];
BEGIN
FOR i in 2..rown LOOP
v_matriz := array_cat(v_matriz,v_array);
END LOOP;
RETURN v_matriz;
END;
$$
LANGUAGE plpgsql volatile;

-----------------------------------------------------------------------------------
I tried this on db2:

CREATE OR REPLACE FUNCTION teste(rown in integer, cols in integer)
RETURN db2inst1.array_teste2 AS
arrayC db2inst1.array_teste;
matrix db2inst1.array_teste2;
BEGIN
--arrayC := db2inst1.array_teste();
FOR I IN 1..cols LOOP
arrayC.extend;
arrayC(i) := 0;
END LOOP;
--matrix := db2inst1.array_teste2(arrayC);
FOR I IN 2..rown LOOP
matrix.extend;
matrix(i) := arrayC;
END LOOP;
RETURN matrix;
END;

array_teste is an integer array[]
array_teste2 is an array_teste array[] (matrix)

it deploys but when i run i got this error:

VALUES DB2INST1.TESTE(INTEGER(2), INTEGER(2))
A "ARRAY" data type is not supported in the context where it is being used.. SQLCODE=-20441, SQLSTATE=428H2, DRIVER=4.13.111
Run of routine failed.
- Roll back completed successfully.

The expected result is: 0 0
0 0

So, anyone knows a way to do this or have examples with matrix on db2?