首页 > 其他分享 >声明一个含有某张表不具备字段的游标

声明一个含有某张表不具备字段的游标

时间:2023-02-19 12:04:52浏览次数:32  
标签:sa sal 张表 游标 batch 字段 post data id


其中,data.*是一张表,然后把其他表中的字段也加到sal_data的游标中

 

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;

 

使用此游标:

声明一个此游标类型的变量:

salary_data_temp sal_data%rowtype;

然后编译此游标

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;

 

 


标签:sa,sal,张表,游标,batch,字段,post,data,id
From: https://blog.51cto.com/u_21817/6066663

相关文章