To create cursor variables, you take two steps. First, you define a REF CURSOR type,then declare cursor variables of that type. You can define REF CURSOR types in any PL/SQL block, subprogram, or package using the syntax TYPE ref_type_name IS REF CURSOR [RETURN return_type]; where ref_type_name is a type specifier used in subsequent declarations of cursor variables and return_type must represent a record or a row in a database table. In the following example, you specify a return type that represents a row in the database table dept:DECLARE TYPE DeptCurTyp IS REF CURSOR RETURN dept%ROWTYPE;REF CURSOR types can be strong (restrictive) or weak (nonrestrictive). As the next example shows, a strong REF CURSOR type definition specifies a return type, but a weak definition does not:DECLARE TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE; -- strong TYPE GenericCurTyp IS REF CURSOR; -- weakStrong REF CURSOR types are less error prone because the PL/SQL compiler lets you associate a strongly typed cursor variable only with type-compatible queries. However, weak REF CURSOR types are more flexible because the compiler lets you associate a weakly typed cursor variable with any query.
type 是定义一种类型,就好像面向对象里面的类一样 is 是说明具体的结构 ref 我不太懂~~~ 楼上可否解释一下,是否相当于一个空的游标?
ref 用于指示该游标为游标变量,即在编译时该游标所指代的语句还不知道,在运行时才能生成该语句
it is clear after i have read the refrences typed by CodeMagic(写错了吧) thanks! Please read it!
TYPE ref_type_name IS REF CURSOR [RETURN return_type];
where ref_type_name is a type specifier used in subsequent declarations of
cursor variables and return_type must represent a record or a row in a database
table. In the following example, you specify a return type that represents a row in the database table dept:DECLARE
TYPE DeptCurTyp IS REF CURSOR RETURN dept%ROWTYPE;REF CURSOR types can be strong (restrictive) or weak (nonrestrictive). As the next
example shows, a strong REF CURSOR type definition specifies a return type, but a
weak definition does not:DECLARE
TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE; -- strong
TYPE GenericCurTyp IS REF CURSOR; -- weakStrong REF CURSOR types are less error prone because the PL/SQL compiler lets
you associate a strongly typed cursor variable only with type-compatible queries.
However, weak REF CURSOR types are more flexible because the compiler lets you
associate a weakly typed cursor variable with any query.
ref 我不太懂~~~ 楼上可否解释一下,是否相当于一个空的游标?
thanks!
Please read it!