You need to define the data type before, and then create a variable to pass like parameter.
>>-CREATE--+------------+--PROCEDURE--procedure-name------------>
'-OR REPLACE-'
>--+--------------------------------------------------------------------------------+-->
'-(--+----------------------------------------------------------------------+--)-'
| .-,----------------------------------------------------------------. |
| V .-IN----. | |
'---+-------+--parameter-name--| data-type |--+--------------------+-+-'
+-OUT---+ '-| default-clause |-'
'-INOUT-'
>--| option-list |--| SQL-procedure-body |---------------------><
data-type
|--+-| built-in-type |---------------+--------------------------|
+-| anchored-variable-data-type |-+
+-array-type-name-----------------+
+-cursor-type-name----------------+
+-distinct-type-name--------------+
'-row-type-name-------------------'
Here, you can see an example of a function that receives an array as parameter. Note the array type was defined before the function. The same is necesary for stored procedures.
--#SET TERMINATOR @
create or replace type my_array_type as varchar(64) array[int]@
create or replace function card (in my_array my_array_type)
returns int
begin
declare card int;
set card = cardinality(my_array);
return card;
end@
create or replace procedure test ()
begin
declare size int;
declare my my_array_type;
set my [1] = 'uno';
set my [2] = 'dos';
set my [3] = 'tres';
set size = card(my);
CALL DBMS_OUTPUT.PUT('Cardinality = ');
CALL DBMS_OUTPUT.PUT_LINE(size);
end@
SET SERVEROUTPUT ON@
call test ()@
Remember that an array is different to a string (CHAR). The arrays are an internal object in DB2, and they need to be defined as variable before use them. Strings can be created as you did: ''. However, they are two different things in DB2.