[英]How to call the oracle function from java. Function returns number
How should I call an Oracle function from Java? 我应该如何从Java调用Oracle函数? The function is supposed to return a number.
该函数应该返回一个数字。
CallableStatement cstmt = mJConn.prepareCall("{? = call fnd_request.submit_request( application => 'FND', program => 'JAVACONINSERT', description => 'CSV to DB Insert via Java' ,start_time => sysdate ,sub_request => FALSE, argument1 => '/home/TEST/java/t1.txt')}");
cstmt.registerOutParameter(1, Types.INTEGER);
cstmt.executeUpdate();
int reqId = cstmt.getInt(1);
System.out.println(reqId);
Try replacing 尝试更换
String call = "{?= CALL Proc(?)}";
with 同
String call = "{CALL Proc(?, ?)}";
The former syntax is for calling a stored function, and the new one is for a stored procedure. 前一种语法用于调用存储的函数,而新语法用于存储的过程。
You can also to swap the order of the bind parameters : 您还可以交换bind参数的顺序:
cs.setString(1, "String");
cs.registerOutParameter(2, Types.INTEGER);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.