A. oracle 存儲過程 if語句
&&用and表示,如:
if 1=1 and 2=2 then
...
end;
||用or表示。
!用not表示。
B. mysql 存儲過程中if控制語句的條件判斷問題
if (@num1 < @time)
AND (@num2 < @time)
AND (@num3 < @time)
then
C. mysql中要新建一個存儲過程,,if語句的判斷條件
BEGIN
IFEXISTS(select1fromrw_yzs_Staticwherepagetype=i_pagetypeandcatalogCode=i_catalogCodeandserviceCode=i_serviceCodeandserviceName=i_serviceName)THEN
updaterw_yzs_StaticsetserviceCode=i_serviceCode,serviceName=i_serviceName,zgbb=i_zgbb,sxmc=i_sxmc,cnqx=i_cnqx,sfbz=i_sfbz,dz=i_dz,bldx=i_bldx,bltj=i_bltj,sxcl=i_sxcl,ckbllc=i_ckbllc,wsbllc=i_wsbllc,blsx=i_blsx,blyj=i_blyj,bz=i_bz,updatetime=NOW()
wherepagetype=i_pagetypeandcatalogCode=i_catalogCodeandserviceCode=i_serviceCodeandserviceName=i_serviceName;
ELSE
INSERTINTOrw_yzs_Static(pagetype,divisioncode,divisionname,catalogCode,catalogName,serviceCode,serviceName,orgGroup,zgbb,sxmc,cnqx,sfbz,dz,bldx,bltj,sxcl,ckbllc,wsbllc,blsx,blyj,bz,updatetime)
VALUES(i_pagetype,i_divisioncode,i_divisionname,i_catalogCode,i_catalogName,i_serviceCode,i_serviceName,i_orgGroup,i_zgbb,i_sxmc,i_cnqx,i_sfbz,i_dz,i_bldx,i_bltj,i_sxcl,i_ckbllc,i_wsbllc,i_blsx,i_blyj,i_bz,now());
ENDIF;
END
例子與回答無關:
這里應該用case when then 這類的吧
這里給個思路,具體用法還是自己去網路吧。應該太多了這種教學。
select case 學分 when <60 then xf=0 from xscj where 學號=xh and 課程名稱 =kcmc
你里你應該新增一個變數來記錄成績的值 才能對此進行IF判斷
D. 存儲過程里if判斷問題
p_cntnumber;
begin
selectcount(1)intop_cntfromtest2;
ifp_cnt>0then
deletefromtest2;
endif;
selectcount(1)intop_cntfromtest4;
ifp_cnt>0then
deletefromtest4;
endif;
insertintotest2
select*fromtest1;
insertintotest4
select*fromtest3;
commit;
end;
E. 求SQL 語句:IF中再加判斷 如何寫 例:假如A=1,並且B=2,那麼返回C=3 ; 剩下A=1的,C都返回4 。
請參考:
SELECT A,B,CASE WHEN B=2 THEN 3 ELSE 4 END C FROM TB WHERE A=1
F. sql存儲過程 如何用IF來判斷變數表內數據是否存在
可以定義一個變數接收值
declare @A as varchar(max),@count integer
select @A='select @count = count(*) from '+ @變數表 + ' where 姓名='+@姓名
exec(@A)
if @count > 0
...
G. 存儲過程的if,else怎麼寫
不同的資料庫中,存儲過程中if else 語句寫法有一些差別。
如果是SQLServer資料庫,存儲過程的if, else語句可以這樣寫:
ifa>b
Begin
print'a'
End
Elseifa<b
Begin
print'b'
End
Else
Begin
print'代碼'
End
Oracle 採用下面這種寫法:
IFtestvalue>100THEN
dbms_output.put_line('100+');
ELSIFtestvalue=100THEN
dbms_output.put_line('100');
ELSE
dbms_output.put_line('100-');
ENDIF;
DB2, MYSQL 是下面這種寫法: ( 與 Oracle 區別在於那個 ELSIF )
IFp_val>100THEN
INSERTINTOoutput_debugVALUES('100+');
ELSEIFp_val=100THEN
INSERTINTOoutput_debugVALUES('100');
ELSE
INSERTINTOoutput_debugVALUES('100-');
ENDIF;
H. 存儲過程 if語句的使用
那就要看一下你的readerinfo表上面是不是有觸發器了:
create proc sp_test
as
update
set rrrid=case when rrrid=0 then 20 else 0 end
where readerid='s001'
I. oracle存儲過程IF判斷的問題
你的if
邏輯有問題:當輸入37的時候
flag>5
肯定結果是1,不會進入else了。
你可以再第一行加上flag<畢春=10
然後試試。
當然你下面的邏輯還有問題,你手鎮耐自己去琢磨琢磨,根據你的需求慢慢改吧!
if
flag>5
and
flag<=10
then
v_value
:=1;
elsif
flag>10
then
v_value
:=2;
elsif
flag<20
then
v_value
:=3;
elsif
flag<39
then
v_value
:=4;
else
v_value
:=5;
end
if;
實在搞不懂邏輯,可旅納以用switch……case……這樣清晰些。