当前位置: 技术问答>java相关
JBUILDER如何执行ORACLE的储存过程
来源: 互联网 发布时间:2015-01-06
本文导语: 我有一个储存过程,声明如下: create or replace procedure CHECKSERVICE(USERID NUMBER,FUNCTIONS VARCHAR2,MONEY OUT NUMBER) is 请问在JDBC下,我怎么执行他,并得到返回值MONEY呢? 我试过以下代码: Calla...
我有一个储存过程,声明如下:
create or replace procedure CHECKSERVICE(USERID NUMBER,FUNCTIONS
VARCHAR2,MONEY OUT NUMBER) is
请问在JDBC下,我怎么执行他,并得到返回值MONEY呢?
我试过以下代码:
CallableStatement cstmt=conn.prepareCall("call checkservice ?,?,?}");
cstmt.setString(1,myuserid);
cstmt.setString(2,"");
cstmt.registerOutParameter(3,java.sql.Types.REAL);
float res=cstmt.executeUpdate();
String outParam=cstmt.getString(3);
错误提示:ORA-00936: 缺少表达式
CallableStatement cstmt=conn.prepareCall("execute
checkservice(?,?,?);");
cstmt.setString(1,myuserid);
cstmt.setString(2,"");
cstmt.setInt(3,0);
float res=cstmt.executeUpdate();
String outParam=cstmt.getString(3);
错误提示:ORA-00936: 缺少表达式
create or replace procedure CHECKSERVICE(USERID NUMBER,FUNCTIONS
VARCHAR2,MONEY OUT NUMBER) is
请问在JDBC下,我怎么执行他,并得到返回值MONEY呢?
我试过以下代码:
CallableStatement cstmt=conn.prepareCall("call checkservice ?,?,?}");
cstmt.setString(1,myuserid);
cstmt.setString(2,"");
cstmt.registerOutParameter(3,java.sql.Types.REAL);
float res=cstmt.executeUpdate();
String outParam=cstmt.getString(3);
错误提示:ORA-00936: 缺少表达式
CallableStatement cstmt=conn.prepareCall("execute
checkservice(?,?,?);");
cstmt.setString(1,myuserid);
cstmt.setString(2,"");
cstmt.setInt(3,0);
float res=cstmt.executeUpdate();
String outParam=cstmt.getString(3);
错误提示:ORA-00936: 缺少表达式
|
import oracle.jdbc.driver.*;
……
CallableStatement cstmt=conn.prepareCall("{call checkservice ?,?,?}");
cstmt.setString(1,"myuserid");
cstmt.setString(2,"fcun");
cstmt.registerOutParameter(3,java.sql.Types.REAL);
float res=cstmt.execute();
ResultSet rs = ((OracleCallableStatement)cstmt).getCursor(3);
while(rs.next())
String outParam=rs.getString(3);
……
CallableStatement cstmt=conn.prepareCall("{call checkservice ?,?,?}");
cstmt.setString(1,"myuserid");
cstmt.setString(2,"fcun");
cstmt.registerOutParameter(3,java.sql.Types.REAL);
float res=cstmt.execute();
ResultSet rs = ((OracleCallableStatement)cstmt).getCursor(3);
while(rs.next())
String outParam=rs.getString(3);