Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用SpringJDBCTemplate调用返回游标的oracle函数_Oracle_Spring_Cursor - Fatal编程技术网

使用SpringJDBCTemplate调用返回游标的oracle函数

使用SpringJDBCTemplate调用返回游标的oracle函数,oracle,spring,cursor,Oracle,Spring,Cursor,您好,我正在使用SpringJDBCTemplate调用接受整数输入的oracle函数 Oracle function is : FUNCTION get_key_types (type_id IN integer) RETURN tcur_key_types_det IS lv_cur tcur_key_types_det; BEGIN IF type_id IS NULL THEN RAISE KEY_ERROR; ELSE OPEN

您好,我正在使用SpringJDBCTemplate调用接受整数输入的oracle函数

Oracle function is :
    FUNCTION get_key_types (type_id IN integer)
  RETURN tcur_key_types_det
IS 
  lv_cur   tcur_key_types_det;
 BEGIN
  IF type_id IS NULL
  THEN
     RAISE KEY_ERROR;
  ELSE
     OPEN lv_cur FOR
          SELECT   key_criteria_cd,
                   key_type_name,
                   KEY_COLUMN_TXT,
                   data_type_cd
            FROM   key_criteria
           WHERE   criteria_type_id = type_id
        ORDER BY   key_type_name;
  END IF;
RETURN lv_cur;
END get_key_types;
我有一个Java类,它从类StoredProcedure扩展而来,该类传递和整数参数以调用oracle函数,如下所示

public class KeyTypeService extends StoredProcedure{
public KeyTypeService(DataSource dataSource,String sqlString) {
    setDataSource(dataSource);
    setFunction(true);
    setSql(sqlString);
    declareParameter(new SqlParameter("type_id",Types.INTEGER));
    declareParameter(new SqlOutParameter("functionName",OracleTypes.CURSOR,new KeyTypeMapper()));
    compile();
}

public Map execute(int category_id) {
    Map<String, Object> inputs = new HashMap<String, Object>();
    inputs.put("type_id", category_id);
    Map output = execute(inputs);
    return output;     
}
int i = 60;
KeyTypeService keyTypeService = new KeyTypeService((DataSource)c.getBean   ("DataSource"),"get_key_types"); 
map = keyTypeService.execute(i);
我得到以下错误,表明我没有传递所需的正确数据类型

PLS-00306:调用“获取密钥类型”时参数的数量或类型错误 ORA-06550:第1行第7列: PL/SQL:忽略语句


非常感谢您的帮助。

因为我的评论是正确的:

out参数必须首先出现

Spring文档可能没有明确讨论顺序,但参数顺序必须与在没有Spring的情况下调用pl/sql函数的顺序相同。即:

out = call pacakge.function(in)

我想out参数必须先到,但我可能弄错了。@tom谢谢你。更改了参数声明的顺序,效果很好。Spring文档中没有提到这方面的内容。明白了。谢谢。错误消息似乎有误导作用。可能是一个更具体的错误消息会有所帮助!