dual 是什么表?具体点谢谢declare v_count number; select count(*) into v_count from cb_t_dj_jgnsr2; if v_count=0 then select 1 from dualend if; 如果是这样,哪里有错?
我的意思是通过SELECT 返回我指定的值,并不是返回第一列的值
select 1 from dual后面要加上分号";" 即:select 1 from dual;Oracle的语法是这样的。
declare v_count number; select count(*) into v_count from cb_t_dj_jgnsr2; if v_count=0 then select 1 from dual;end if; select 1 from cb_t_dj_jgnsr2
declare v_count number; select count(*) into v_count from cb_t_dj_jgnsr2; if v_count=0 then select 1 from dual;end if; select 1 from cb_t_dj_jgnsr2加了报错
select 1 from dual
你的目的是什么 declare v_count number; select count(*) into v_count from cb_t_dj_jgnsr2; if v_count=0 then select 1 into v_count from dual; end if; dbms_output.put_line(v_count); end;
其实是这样的,我是想判断一张表有没有符合条件的记录,有就更新,没有就插入 有个判断 在调试阶段用select 1 ,select 2zhezhong zai MSSQL可以实现的方法来进行验证 本来写 if exists(select count(*) from biao1) then select 1; elsif select 2; end if全是错误
其实是这样的,我是想判断一张表有没有符合条件的记录,有就更新,没有就插入 有个判断 在调试阶段用select 1 ,select 2这种在MSSQL可以实现的方法来进行验证 本来写 if exists(select count(*) from biao1) then select 1; elsif select 2; end if全是错误
if exists(select count(*) from biao1) then select 1; else select 2; end if
declare v_count number; select count(*) into v_count from cb_t_dj_jgnsr2 where 条件; if v_count=0 then insert into tb select * from cb_t_dj_jgnsr2 where 条件; else update tb set ...; end if; commit; dbms_output.put_line(v_count); end;
连这个都运行错误 declare v_count number;
select count(*) into v_count from cb_t_dj_jgnsr2 ; dbms_output.put_line(v_count);我用的是PL/SQL工具 ora-06550 错误
declare v_count number; begin select count(*) into v_count from crmii.tuser t where t.userid='admin' ; if v_count>=1 then update aa t1 set t1.a=5; end if; end ;
--块结构!!! set serveroutput ondeclare v_count number; begin select count(*) into v_count from cb_t_dj_jgnsr2 ; dbms_output.put_line(v_count); exception when others then dbms_output.put_line('can not find data!'); end;
select count(*) into v_count from cb_t_dj_jgnsr2;
if v_count=0 then
select 1 from dualend if; 如果是这样,哪里有错?
即:select 1 from dual;Oracle的语法是这样的。
select count(*) into v_count from cb_t_dj_jgnsr2;
if v_count=0 then
select 1 from dual;end if;
select 1 from cb_t_dj_jgnsr2
declare v_count number;
select count(*) into v_count from cb_t_dj_jgnsr2;
if v_count=0 then
select 1 from dual;end if;
select 1 from cb_t_dj_jgnsr2加了报错
declare
v_count number;
select count(*) into v_count from cb_t_dj_jgnsr2;
if v_count=0 then
select 1 into v_count from dual;
end if;
dbms_output.put_line(v_count);
end;
有个判断
在调试阶段用select 1 ,select 2zhezhong zai MSSQL可以实现的方法来进行验证
本来写 if exists(select count(*) from biao1) then
select 1;
elsif
select 2;
end if全是错误
有个判断
在调试阶段用select 1 ,select 2这种在MSSQL可以实现的方法来进行验证
本来写 if exists(select count(*) from biao1) then
select 1;
elsif
select 2;
end if全是错误
if exists(select count(*) from biao1) then
select 1;
else
select 2;
end if
declare
v_count number;
select count(*) into v_count from cb_t_dj_jgnsr2 where 条件;
if v_count=0 then
insert into tb select * from cb_t_dj_jgnsr2 where 条件;
else
update tb set ...;
end if;
commit;
dbms_output.put_line(v_count);
end;
declare
v_count number;
select count(*) into v_count from cb_t_dj_jgnsr2 ;
dbms_output.put_line(v_count);我用的是PL/SQL工具 ora-06550 错误
v_count number;
begin
select count(*) into v_count from crmii.tuser t where t.userid='admin' ;
if v_count>=1
then update aa t1 set t1.a=5;
end if;
end ;
set serveroutput ondeclare
v_count number;
begin
select count(*) into v_count from cb_t_dj_jgnsr2 ;
dbms_output.put_line(v_count);
exception when others then
dbms_output.put_line('can not find data!');
end;