Blogspot rss feed not updating
Even though the example cursor variable is defined, the record can not use it because the cursor variable return type is not defined.
The example below attempts to create a cursor %rowtype variable for processing.
But what happens when a cursor variable is defined with a SQL statement but returns unexpected values?
Below is an example of defining a cursor variable of one type and the record as another.
Before assigning a cursor variable, a cursor type must be defined.
type author_cursor is ref cursor; This "REF CURSOR" is a weak typed cursor variable because it does not define the datatype the cursor will return. type author_cursor is ref cursor returning author%rowtype; By strongly typing the cursor variable, you define what the cursor can return.
REF Cursors A REF CURSOR or cursor variable is just a reference or a handle to a static cursor.The cursor variable can also be returned by a function and assigned to another variable.The ref cursor variable is not a cursor, but a variable that points to a cursor.By changing the definition of the cursor type to a strongly typed definition, the compiler will catch this error when the code is compiled.SQL declare 2 type auth_cursor is ref cursor 3 return book%rowtype; 4 c1 auth_cursor; 5 r_c1 author%rowtype; 6 begin 7 open c1 for select * from book; 8 fetch c1 into r_c1; 9 close c1; 10 end; 11 / fetch c1 into r_c1; * ERROR at line 8: ORA-06550: line 8, column 5: PLS-00394: wrong number of values in the INTO list of a FETCH statement ORA-06550: line 8, column 5: PL/SQL: SQL Statement ignored Now the compiler catches the error.