- Declare CursorMy_curIs SelectEmpno, deptnoFromEmp;
- Employee_id emp. empno % type;
- Dept_id emp. deptno % type;
- Begin
- OpenMy_cur;
- FetchMy_curIntoEmployee_id, dept_id;
- While my_cur % found loop
- Dbms_output.put_line (employee_id |'Shit'| Dept_id );
- FetchMy_curIntoEmployee_id, dept_id;
- EndLoop;
- End;
|
Use row variables to obtain cursor Information
- Declare CursorMycurIs Select*FromEmp;
- Var_emp emp % rowtype;
- Begin
- OpenMycur;
- FetchMycurIntoVar_emp;
- While mycur % found loop
- Dbms_output.put_line (var_emp.ename |':'| + To_char (var_emp.hiredate,'Yyyy-MM-dd'));
- FetchMycurIntoVar_emp;
- EndLoop;
- End;
|
Implicit cursor
- DeclareVar_countInteger;
- Begin
- UpdateASetEname ='B';
- Var_count: = SQL % rowcount;
- Dbms_output.put_line (to_char (var_count ));
- End;
|
Dynamic Cursor
Definition
Declare type emp_cur_type is ref cursor return emp % rowtype;
New_emp_cur_type emp_cur_type;
Open new_emp_cur_type for select * from emp;