【发布时间】:2023-04-02 08:25:01
【问题描述】:
我是 PL/SQL 的初学者,所以这个问题难倒我。我有一些 PL/SQL 代码:
create or replace package p2 as
procedure show_students(ref_cursor out sys_refcursor);
...
end;
/
show errors
create or replace package body p2 as
procedure show_students(ref_cursor out sys_refcursor) is
begin
open ref_cursor for SELECT * FROM students;
end;
...
end;
/
show errors
我也有这个 Java 代码:
public static void showTable( int option, Connection conn ) {
try {
CallableStatement cs = conn.prepareCall( "begin p2.show_students(?); end;" ) ;
cs.registerOutParameter( 1, OracleTypes.CURSOR ) ;
cs.execute() ;
ResultSet rs = (ResultSet)cs.getObject( 1 ) ;
while ( rs.next()) {
System.out.println( rs.getString(1) + "\t" +
rs.getString(2) + "\t" + rs.getString(3) +
rs.getString(4) +
"\t" + rs.getDouble(5) + "\t" +
rs.getString(6)) ;
}
cs.close() ;
}
catch( SQLException ex ) {
System.out.println( "SQL Exception " + ex.getMessage()) ;
}
当我运行 Java 程序时,我收到以下错误:
SQL Exception ORA-06550: line 1, column 7:
PLS-00201: identifier 'P2.SHOW_STUDENTS' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
...我不知道是什么导致了这个问题。非常感谢任何帮助!
【问题讨论】: