Definition and Application of pl SQL with parameter cursor, pl cursor

Source: Internet
Author: User

Definition and Application of pl SQL with parameter cursor, pl cursor
CURSOR cursor_name (parameter_name datatype) IS select_statement; -- only the type can be specified and the specific size cannot be specified.
OPEN cursor_name (parameter value );
FECTH cursor_name INTO variable ,...;

CLOSE cursor_name;

  1. Declare
  2. Cursor emp_cursor (v_depnto number) is select ename, sal from scott. emp where deptno = v_depnto order by empno;
  3. Emp_record emp_cursor % rowtype;
  4. V_dno number;
  5. Begin
  6. V_dno: = & no;
  7. If not emp_cursor % isopen then
  8. Open emp_cursor (v_dno );
  9. End if;
  10. Null;
  11. Loop
  12. Fetch emp_cursor into emp_record;
  13. Exit when emp_cursor % notfound;
  14. Dbms_output.put_line ('name: '| emp_record.ename |', salary: '| emp_record.sal );
  15. End loop;
  16. Null;
  17. If emp_cursor % isopen then
  18. Close emp_cursor;
  19. End if;
  20. End;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.