如何在Java中调用一个返回游标的存储过程
1个回答
展开全部
import oracle.jdbc.*;
...
CallableStatement cstmt;
ResultSet cursor;
// Use a PL/SQL block to open the cursor
//Additional Oracle Type Extensions
cstmt = conn.prepareCall
("begin open ? for select ename from emp; end;";
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
cstmt.execute();
cursor = ((OracleCallableStatement)cstmt).getCursor(1);
// Use the cursor like a normal ResultSet
while (cursor.next ())
{System.out.println (cursor.getString(1));}
...
CallableStatement cstmt;
ResultSet cursor;
// Use a PL/SQL block to open the cursor
//Additional Oracle Type Extensions
cstmt = conn.prepareCall
("begin open ? for select ename from emp; end;";
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
cstmt.execute();
cursor = ((OracleCallableStatement)cstmt).getCursor(1);
// Use the cursor like a normal ResultSet
while (cursor.next ())
{System.out.println (cursor.getString(1));}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询