Oracle cursor (iii) REF Dynamic Cursor

Source: Internet
Author: User
Tags oracle cursor


Oracle cursor (iii) REF Dynamic Cursor link: Oracle cursor (I) Explicit cursor http://www.bkjia.com/database/201208/150342.html#oraclecursor (ii) Implicit cursor http://www.bkjia.com/database/201208/150344.html REF dynamic cursor is used to process query result sets for multiple rows
In the same PLSQL block, the REF dynamic cursor is different from the specific query binding.
It is bound only when the cursor is opened. Therefore, it is usually used to query the steps for using the dynamic cursor when the statement needs to be dynamically determined during running.
First define a REF Dynamic Cursor type www.2cto.com

Example:
Dynamic cursors are classified into strong and weak types.
Weak type example
Dynamic Cursor example
Generate employee or department information
[SQL] <strong> <span style = "font-size: 18px;"> declare type refcur_t is ref cursor; refcur refcur_t; p_id number; p_name varchar2 (50 ); sel varchar2 (1): = upper (substr ('% tab',); begin if sel = 'E' then open refcur for select id, name from employees; dbms_output.put_line ('employee information'); elsif sel = 'D' then www.2cto.com open refcur for select department_id, department_name from departments; dbms_output.put_line ('department information '); else dbms_output.put_line ('reinput '); return; end if; fetch refcur into p_id, p_name; while refcur % found loop dbms_output.put_line ('#' | p_id | 'P _ name'); fetch refcur into p_id, p_name; end loop; close refcur; end; </span> </strong>
 

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.