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……这样清晰些。