Oracle 多層游標(biāo)的嵌套實操
以下的文章主要介紹的是Oracle 多層游標(biāo)的嵌套,以及有對Oracle 游標(biāo)的具體概念的描述,以下文章主要是對Oracle 多層游標(biāo)的嵌套的實際操作步驟的描述,希望會給你帶來一些幫助在此方面。
不是這樣的,存儲過程中不是非要用游標(biāo)啊,他有輸入和輸出參數(shù),只要在過程中做相應(yīng)的處理就會返回輸出參數(shù)。游標(biāo)的作用主要是為了循環(huán)提取數(shù)據(jù),游標(biāo)分隱性游標(biāo)和顯性游標(biāo)。
舉個例子(顯性游標(biāo)):
CURSOR 游標(biāo)名 IS SELECT 語句;
.....
WHILE 游標(biāo)名% found LOOP
.....
END LOOP;
其中的SELECT 語句提取的是一列值,然后每次取一個進(jìn)行下面的循環(huán)。
(隱性游標(biāo)):
for 游標(biāo)名 in (SELECT 語句)loop
.....
.....
END LOOP;
其中的SELECT 語句提取的也是一列值,然后每次取一個進(jìn)行下面的循環(huán)。
Oracle 多層游標(biāo)嵌套:一般的多層嵌套可以用幾個表聯(lián)合起來查詢就能替代,但有時卻不能代替,比如,第二個要查詢的值是***個查出值后再進(jìn)行l(wèi)ike運(yùn)算
- declare
- v_0 number;
- v_1 number;
- cursor c1 is select productordernumber from his_productorder@pro_crm where productid in (9000045516);
- cursor c2 is select cust_order_id from suf_cust_order_q_his where cust_order_num like v_0||'%';
- cursor c3 is select * from suf_work_order_q_his where cust_order_id=v_1;
- begin
- for i in c1 loop
- v_0:=i.productordernumber;
- for j in c2 loop
- v_1:=j.cust_order_id;
- for k in c3 loop
- dbms_output.put_line(k.work_order_id||' '||k.status);
- end loop;
- end loop;
- end loop;
以上的相關(guān)內(nèi)容就是對Oracle 多層游標(biāo)嵌套的介紹,望你能有所收獲。