oracle 聲明游標(不具備字段)規(guī)則應(yīng)用
更新時間:2012年11月23日 09:43:14 作者:
在開發(fā)過程中可能會聲明一個含有某張表不具備字段的游標,來解決特殊問題,本文將詳細介紹這類問題,需要了解更多的朋友可以參考下
在開發(fā)過程中可能會聲明一個含有某張表不具備字段的游標,來解決特殊問題,本文將詳細介紹這類問題,需要了解更多的朋友可以參考下
其中,data.*是一張表,然后把其他表中的字段也加到sal_data的游標中
Sql代碼
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;
使用此游標:
聲明一個此游標類型的變量:
Sql代碼
salary_data_temp sal_data%rowtype;
然后編譯此游標
Sql代碼
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;
其中,data.*是一張表,然后把其他表中的字段也加到sal_data的游標中
Sql代碼
復(fù)制代碼 代碼如下:
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;
使用此游標:
聲明一個此游標類型的變量:
Sql代碼
復(fù)制代碼 代碼如下:
salary_data_temp sal_data%rowtype;
然后編譯此游標
Sql代碼
復(fù)制代碼 代碼如下:
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;
相關(guān)文章
Oracle 插入超4000字節(jié)的CLOB字段的處理方法
我們可以通過創(chuàng)建單獨的OracleCommand來進行指定的插入,即可獲得成功,這里僅介紹插入clob類型的數(shù)據(jù),blob與此類似,這里就不介紹了,下面介紹兩種辦法2009-07-07
Oracle數(shù)據(jù)庫表名支持的最大長度是多少
這篇文章主要介紹了Oracle數(shù)據(jù)庫表名支持的最大長度,本文通過Oracle標識符確認了表名的最大支持字符串為30個字符,需要的朋友可以參考下2014-08-08
oracle實現(xiàn)動態(tài)查詢前一天早八點到當天早八點的數(shù)據(jù)功能示例
這篇文章主要介紹了oracle實現(xiàn)動態(tài)查詢前一天早八點到當天早八點的數(shù)據(jù)功能,涉及Oracle針對日期時間的運算與查詢相關(guān)操作技巧,需要的朋友可以參考下2019-10-10
Oracle + mybatis實現(xiàn)對數(shù)據(jù)的簡單增刪改查實例代碼
這篇文章主要給大家介紹了關(guān)于利用Oracle + mybatis如何實現(xiàn)對數(shù)據(jù)的簡單增刪改查的相關(guān)資料,文中圖文介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-10-10

