日期:2014-05-16 浏览次数:20403 次
CREATE OR REPLACE PACKAGE TESTS AS --包头部分 TYPE MYUSER_CURSOR IS REF CURSOR; --类型对象为游标 PROCEDURE PROC_TUSER(ID in varchar2,MYUSER out MYUSER_CURSOR); END TESTS;
CREATE OR REPLACE PACKAGE TESTS BODY AS --包头部分 PROCEDURE PROC_TUSER(ID in varchar2,MYUSER out MYUSER_CURSOR) AS BEGIN OPEND MYUSER FOR SELECT * FROM USERS WHERE UID=ID; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('获取用户信息出错!'); END PROC_TUSER; END TESTS;
oracle.jdbc.OracleCallableStatement csmt = (oracle.jdbc.OracleCallableStatement)jdbc.getCallStmt(“{call TESTS. PROC_TUSER (?,?)}”); csmt.setString(1,id); csmt.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR); csmt.execute(); ResultSet rs =csmt.getCursor(2);
java.sql.CallableStatement csmt = jdbc.getCallStmt(“{call TESTS. PROC_TUSER (?,?)}”); csmt.setString(1,id); csmt.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR); csmt.execute(); java.sql.ResultSet rs = (java.sql.ResultSet)csmt.getObject(2);