我无法调用具有输入参数作为整数数组的存储过程。
存储过程声明如下
CREATE OR REPLACE PROCEDURE TESTSCHEMA.TESTARRAY
(IN CHECKSTATUS INTEGER,
IN JOBID INTARRAY)
数组声明为
CREATE TYPE INTARRAY AS INTEGER ARRAY[]@
当我尝试使用
调用该过程时 CALL TESTSCHEMA.TESTARRAY( 1 , array[21,22,23] )@
我收到以下错误 -
在“ARRAY [”之后发现意外的令牌“ARRAY [”。预期的令牌可能包括:“”.. SQLCODE = -104,SQLSTATE = 42601,DRIVER = 3.63.123 SQL代码:-104,SQL状态:42601'
我似乎无法找到任何其他方法来做到这一点?有人可以帮忙吗?
还需要找到一种在Java中传递数组的方法。
答案 0 :(得分:1)
SQL PL数组只能在SQL PL上下文中使用。您需要声明INTARRAY
类型的变量,并使用该变量从复合SQL语句中调用您的过程:
db2inst1@blusrv:~> db2 "create type INTARRAY AS INTEGER ARRAY[]"
DB20000I The SQL command completed successfully.
db2inst1@blusrv:~> db2 "create or replace procedure testarray(in checkstatus integer, in jobid intarray) begin call dbms_output.put_line('testarray'); end"
DB20000I The SQL command completed successfully.
db2inst1@blusrv:~> db2 set serveroutput on
DB20000I The SET SERVEROUTPUT command completed successfully.
db2inst1@blusrv:~> db2 "begin declare v intarray; set v = array[21,22,23]; call testarray(1,v); end"
DB20000I The SQL command completed successfully.
testarray