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;