oracle if else語(yǔ)句使用介紹
已發(fā)貨,在arrival_date中賦值為今天后的7天
已訂貨,在arrival_date中賦值為今天后的一個(gè)月
既無(wú)訂貨又無(wú)發(fā)貨,則在arrival_date中賦值為今天后的兩個(gè)月,
并在order表中增加一條新的訂單記錄。
product_status的列值為'shipped'和'ordered'
inventory:
product_idnumber(6)
product_descriptionchar(30)
product_statuschar(20)
std_shipping_qtynumber(3)
contract_item:
product_id number(6)
contract_nonumber(12)
item_nonumber(6)
arrival_datedate
order:
order_idnumber(6)
product_idnumber(6)
qtynumber(3)
代碼:
declare
i_product_id inventory.product_id%type;
i_product_description inventory.product_description%type;
i_product_status inventory.product_status%type;
i_std_shipping_qty inventory.std_shipping_qty%type;
begin
//sql語(yǔ)句,將查詢出來(lái)的值放到定義的變量中
select product_id, product_description, product_status, std_shipping_qty
into i_product_id, i_product_description, i_product_status, i_std_shipping_qty
from inventory where product_id=(
select product_id from contract_item where contract_no=&&contract_no and item_no=&&item_no
);
if i_product_status='shipped' then
update contract_item set arrival_date=sysdate+7 contract_no=&&contract_no and item_no=&&item_no;
//這里的elseif 是連著寫的
elseif i_product_status='ordered'then
updatecontract_item
setarrival_date=add_months(sysdate,1)//加一個(gè)月
whereitem_no=&&itemnoandcontract_no=&&contractno;
else
updatecontract_item
setarrival_date=add_months(sysdate,2)
whereitem_no=&&itemnoandcontract_no=&&contractno;
insertintoorders
values(100,i_product_id,i_std_shipping_qty);
end if;
end if;
commit;
end;
相關(guān)文章
Oracle 區(qū)塊鏈表創(chuàng)建過(guò)程詳解
Oracle 區(qū)塊鏈表是一個(gè)具有防篡改功能的表,只能插入數(shù)據(jù),同時(shí)提供了表級(jí)和行級(jí)的保留期限,接下來(lái)通過(guò)本文給大家分享Oracle區(qū)塊鏈平臺(tái)的創(chuàng)建過(guò)程,感興趣的朋友一起看看吧2021-05-05
ORACLE應(yīng)用經(jīng)驗(yàn)(1)
ORACLE應(yīng)用經(jīng)驗(yàn)(1)...2007-03-03
Oracle出現(xiàn)超出打開游標(biāo)最大數(shù)的解決方法
這篇文章主要介紹了Oracle出現(xiàn)超出打開游標(biāo)最大數(shù)的解決方法,涉及針對(duì)Oracle游標(biāo)位置的判斷與處理技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2016-06-06
分享Oracle 11G Client 客戶端安裝步驟(圖文詳解)
這篇文章主要介紹了分享Oracle 11G Client 客戶端安裝步驟(圖文詳解),非常具有實(shí)用價(jià)值,需要的朋友可以參考下。2016-12-12
oracle錯(cuò)誤ORA-00054資源正忙解決辦法
ORA-00054是Oracle數(shù)據(jù)庫(kù)中的一個(gè)常見錯(cuò)誤,表示用戶試圖在正在被鎖定的資源上執(zhí)行不允許的操作,導(dǎo)致資源處于忙碌狀態(tài),下面這篇文章主要給大家介紹了關(guān)于oracle錯(cuò)誤ORA-00054資源正忙的解決辦法,需要的朋友可以參考下2024-01-01
Oracle數(shù)據(jù)庫(kù)性能優(yōu)化技術(shù)開發(fā)者網(wǎng)絡(luò)Oracle
Oracle數(shù)據(jù)庫(kù)性能優(yōu)化技術(shù)開發(fā)者網(wǎng)絡(luò)Oracle...2007-03-03
oracle數(shù)據(jù)庫(kù)慢查詢SQL實(shí)例詳解
一般的業(yè)務(wù)系統(tǒng)如果遇到性能問題,絕大部分都是來(lái)自數(shù)據(jù)庫(kù)的,有的業(yè)務(wù)一個(gè)查詢執(zhí)行時(shí)間好幾秒,這就是我們說(shuō)說(shuō)的SQL慢查詢,這篇文章主要給大家介紹了關(guān)于oracle數(shù)據(jù)庫(kù)慢查詢SQL的相關(guān)資料,需要的朋友可以參考下2024-06-06
Oracle進(jìn)行數(shù)據(jù)庫(kù)升級(jí)和降級(jí)的操作代碼
數(shù)據(jù)庫(kù)升級(jí)是一個(gè)復(fù)雜的過(guò)程,涉及到備份現(xiàn)有數(shù)據(jù)、安裝新版本的數(shù)據(jù)庫(kù)軟件、遷移數(shù)據(jù)和應(yīng)用程序的兼容性測(cè)試等步驟,數(shù)據(jù)庫(kù)降級(jí)通常比升級(jí)更具挑戰(zhàn)性,所以本文給大家介紹了Oracle進(jìn)行數(shù)據(jù)庫(kù)升級(jí)和降級(jí)的操作,需要的朋友可以參考下2024-09-09
修改ORACLE數(shù)據(jù)庫(kù)密碼有效期的方法
這篇文章主要介紹了修改ORACLE數(shù)據(jù)庫(kù)密碼有效期的方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-09-09
oracle11gR2使用exp導(dǎo)出命令時(shí)報(bào)EXP-00011錯(cuò)誤的解決方法
這篇文章主要介紹了oracle11gR2使用exp導(dǎo)出命令時(shí)報(bào)EXP-00011錯(cuò)誤的解決方法,大家參考使用吧2014-01-01

