我定义了一个Package如下CREATE OR REPLACE Package Package1
as
Type AccountList_Cursor is ref cursor;
Procedure Proc1(yb out AccountList_Cursor);
end Package1;
在代码块中使用declare
ybb Package1.AccountList_Cursor;
rowobj Account%rowtype;
begin
Package1.Proc1(ybb);
open ybb;
for rowobj in ybb loop
dbms_output.put_line(rowobj.account);
end loop;
end;提示错误:
ORA-06550: 第 6 行, 第 3 列:
PLS-00382: 表达式类型错误
ORA-06550: 第 6 行, 第 3 列:
PL/SQL: SQL Statement ignored
ORA-06550: 第 7 行, 第 17 列:
PLS-00221: 'YBB' 不是过程或尚未定义
ORA-06550: 第 7 行, 第 3 列:
PL/SQL: Statement ignored但我在jdbc中调用是可以的String url="jdbc:oracle:thin:@127.0.0.1:1521:orcl";
String user="scott";
String pwd="123";
Connection conn=null;
CallableStatement stmt=null;
ResultSet rs=null;
try{
conn= DriverManager.getConnection(url, user, pwd);
stmt=conn.prepareCall("{call Package1.Proc1(?)}");
stmt.registerOutParameter(1,OracleTypes.CURSOR);
stmt.execute();
rs=(ResultSet) stmt.getObject(1);
while(rs.next()){
System.out.println(rs.getString(1));
}
}catch(Exception ex){
ex.printStackTrace();
}finally{
if(rs!=null){
try{
rs.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
if(stmt!=null){
try{
stmt.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
if(conn!=null){
try{
conn.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
}
as
Type AccountList_Cursor is ref cursor;
Procedure Proc1(yb out AccountList_Cursor);
end Package1;
在代码块中使用declare
ybb Package1.AccountList_Cursor;
rowobj Account%rowtype;
begin
Package1.Proc1(ybb);
open ybb;
for rowobj in ybb loop
dbms_output.put_line(rowobj.account);
end loop;
end;提示错误:
ORA-06550: 第 6 行, 第 3 列:
PLS-00382: 表达式类型错误
ORA-06550: 第 6 行, 第 3 列:
PL/SQL: SQL Statement ignored
ORA-06550: 第 7 行, 第 17 列:
PLS-00221: 'YBB' 不是过程或尚未定义
ORA-06550: 第 7 行, 第 3 列:
PL/SQL: Statement ignored但我在jdbc中调用是可以的String url="jdbc:oracle:thin:@127.0.0.1:1521:orcl";
String user="scott";
String pwd="123";
Connection conn=null;
CallableStatement stmt=null;
ResultSet rs=null;
try{
conn= DriverManager.getConnection(url, user, pwd);
stmt=conn.prepareCall("{call Package1.Proc1(?)}");
stmt.registerOutParameter(1,OracleTypes.CURSOR);
stmt.execute();
rs=(ResultSet) stmt.getObject(1);
while(rs.next()){
System.out.println(rs.getString(1));
}
}catch(Exception ex){
ex.printStackTrace();
}finally{
if(rs!=null){
try{
rs.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
if(stmt!=null){
try{
stmt.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
if(conn!=null){
try{
conn.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货