oracle存储过程中写IF ELES

我想在if中写判断查询语句是否成立,还有if中能不能写 || 。
条件多了怎么办。。。
最新回答
松你手

2024-11-22 19:19:20

if 条件 then
语句
elsif 条件 then
语句
else
语句
end if;
卩s团团丨

2024-11-22 10:50:08

if a is not null or b != '01' then
......
elsif (b =1 or b=2) and a is null then
......
end if;
追问
if 或者是 elsif 中再写个if 要结束的话,还用不用在if下写个end if?
追答
用,这些都是成对出现的,例如:
if a is not null or b != '01' then
......
elsif (b =1 or b=2) and a is null then
if b=1 then
......
end if;
......

end if;
一个转身的距离。

2024-11-22 19:38:54

if 1=1 then
--
eles
--
end if ;
追问
能写个存储过程带IF的例子么
追答
create or replace procedure update_ply_base_status is
vOrderId TB_TSWWW_PLY.C_ORDERID_RELATE%TYPE;
vProdNo TB_TSWWW_PLY.c_Prod_No%TYPE;
vFinS TB_TSWWW_PLY.c_Fin_Stat%TYPE;
vState TB_TSWWW_PLY.c_Stat%TYPE;

CURSOR CUR_EDR IS
select t.c_orderid_relate,
t.c_prod_no,
t.c_fin_stat,
t.c_stat
from TB_TSWWW_PLY t where t.t_crt_date>=sysdate-1/24 or t.t_upd_date>=sysdate-1/24;

BEGIN

BEGIN
OPEN CUR_EDR;
LOOP
FETCH CUR_EDR
INTO vOrderId, vProdNo, vFinS, vState;
EXIT WHEN CUR_EDR%NOTFOUND;

IF vFinS='0' and vState='1' THEN
BEGIN
IF substr(vOrderId,0,2)='00' THEN

update t_ply_base a set a.c_order_status='005' where a.c_orderid_relate=vOrderId;

ELSE

update t_ply_base a set a.c_order_status='005' where a.c_orderid_relate=vOrderId and a.c_prod_no=vProdNo;

END IF;
END;

END IF;

IF vFinS='1' and vState='1' THEN
BEGIN
IF substr(vOrderId,0,2)='00' THEN

update t_ply_base a set a.c_order_status='008',a.c_payment_status='1' where a.c_orderid_relate=vOrderId;

ELSE

update t_ply_base a set a.c_order_status='008',a.c_payment_status='1' where a.c_orderid_relate=vOrderId and a.c_prod_no=vProdNo;

END IF;
END;

END IF;

END LOOP;
CLOSE CUR_EDR;
COMMIT;
END;

end update_ply_base_status;
下一個街角

2024-11-22 14:28:55

恩 然后呢!