Oracle Declaration cursor (No field) rule application _oracle

Source: Internet
Author: User
In the development process may be declared that contains a table does not have a field cursor, to solve special problems, this article will detail this type of problem, need to know more friends can refer to the

Where data.* is a table and then adds fields from other tables to the Sal_data cursor
SQL code
Copy Code code as follows:

Cursor Sal_data (cp_center_temp_id varchar2) is
Select Data.*,
Post.id emp_post_id,
Doc. SALARY_TAX_BD SA_TAX_BD,
Batch.bill_year_month Bill_year_month,
Batch.id batch_id,
post.emp_id employee_id
From Sa_salary_data data
Left JOIN Sa_salary_batch Batch
On data.sa_batch_id = Batch.id
Left JOIN Sa_salary_document Doc
On data.sa_doc_id = Doc.id
Left Join Pb_emp_post Post
On doc.emp_post_id = Post.id
Left JOIN Pb_send Send
On post.send_id = Send.id
where send.cost_center_id = cp_center_temp_id;

Use this cursor:
Declares a variable of this cursor type:
SQL code
Copy Code code as follows:

Salary_data_temp Sal_data%rowtype;

This cursor is then compiled
SQL code
Copy Code code as follows:

Open Sal_data (center_temp.id);
Loop
Fetch Sal_data
into Salary_data_temp;
Exit when Sal_data%notfound;
--todo
End Loop;
Colse Sal_data;

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.