我们经常用到这个CREATE OR REPLACE PACKAGE asdf AS type report_row_type is ref cursor 谁能帮我具体解释一下ref的具体含义 和 用法 先谢谢了
------解决方案--------------------
在这里ref coursor是一起定义一个变量类型。不能分开的。 官方解释如下: Support for Oracle REF CURSOR Types Oracle PL/SQL and the Oracle SQLJ implementation support the use of cursor variables that represent database cursors.
Overview of REF CURSOR Types
Cursor variables are functionally equivalent to JDBC result sets, essentially encapsulating the results of a query. A cursor variable is often referred to as a REF CURSOR, but REF CURSOR itself is a type specifier, and not a type name. Instead, named REF CURSOR types must be specified. The following example shows a REF CURSOR type specification:
TYPE EmpCurType IS REF CURSOR;
Stored procedures and stored functions can return parameters of Oracle REF CURSOR types. You must use PL/SQL to return a REF CURSOR parameter. You cannot accomplish this using SQL alone. A PL/SQL stored procedure or function can declare a variable of some named REF CURSOR type, execute a SELECT statement, and return the results in the REF CURSOR variable.
See Also:
Oracle Database PL/SQL User's Guide and Reference REF CURSOR Types in SQLJ
In the Oracle SQLJ implementation, a REF CURSOR type can be mapped to iterator columns or host variables of any iterator class type or of the java.sql.ResultSet type, but host variables can be OUT only. Support for REF CURSOR types can be summarized as follows:
As result expressions for stored function returns
As output host expressions for stored procedure or function output parameters
As output host expressions in INTO-lists
As iterator columns
You can use the SQL CURSOR operator for a nested SELECT within an outer SELECT statement. This is how you can write a REF CURSOR object to an iterator column or ResultSet column in an iterator, or write a REF CURSOR object to an iterator host variable or ResultSet host variable in an INTO-list.