国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > Oracle > 正文

oracle if else語句使用介紹

2024-08-29 13:55:54
字體:
來源:轉載
供稿:網友
接收contract_no和item_no值,在inventory表中查找,如果產品:W
已發貨,在arrival_date中賦值為今天后的7天W
已訂貨,在arrival_date中賦值為今天后的一個月W
既無訂貨又無發貨,則在arrival_date中賦值為今天后的兩個月,W
并在order表中增加一條新的訂單記錄。W

product_status的列值為'shipped'和'ordered'W
inventory:W
product_idWnumber(6)W
product_descriptionWchar(30)W
product_statusWchar(20)W
std_shipping_qtyWnumber(3)W
contract_item:W
product_id number(6)W
contract_noWnumber(12)W
item_noWnumber(6)W
arrival_dateWdateW
order:W
order_idWnumber(6)W
product_idWnumber(6)W
qtyWnumber(3)W

代碼:

復制代碼 代碼如下:


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語句,將查詢出來的值放到定義的變量中
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'WthenW
updateWcontract_itemW
setWarrival_date=add_months(sysdate,1)W//加一個月
whereWitem_no=&&itemnoWandWcontract_no=&&contractno;W
else
updateWcontract_itemW
setWarrival_date=add_months(sysdate,2)W
whereWitem_no=&&itemnoWandWcontract_no=&&contractno;W
insertWintoWordersW
values(100,i_product_id,i_std_shipping_qty);W
end if;
end if;
commit;
end;

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阿拉善盟| 方山县| 岳普湖县| 晋城| 同仁县| 焦作市| 佛山市| 化州市| 潞城市| 连州市| 乌兰察布市| 江安县| 洛隆县| 阿拉善左旗| 新乡市| 平和县| 建始县| 福安市| 格尔木市| 新田县| 旅游| 灌阳县| 滦南县| 宁阳县| 囊谦县| 宝应县| 南城县| 凯里市| 沧州市| 建平县| 长春市| 新平| 连南| 星座| 沙田区| 三穗县| 于田县| 鹤壁市| 项城市| 霞浦县| 寻乌县|