Cursor writing for Oracle dynamic table names

Source: Internet
Author: User

During development, we often encounter the cursor Writing of dynamic table names, which happens in the work, as shown below:

 

Declare
Stralltable varchar2 (100 );
Type cur_typ is ref cursor;
C cur_typ;

C_id number (18 );
C_code varchar2 (100 );
Begin
For c_table in (select T. table_name
From user_tab_columns t
Where T. table_name like upper ('pne _ % ')
And T. column_name = 'code') loop

Stralltable: = 'select ID, code from' |
C_table.table_name;
Open C for stralltable;
Loop
Fetch C
Into c_id, c_code;
Exit when C % notfound;

-- You can write your own processing code here.
End loop;

Close C;
End loop;
End;

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.