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

