在MSSQL里
select 1  
是可以执行的在ORACLE里类似的这种怎么写?验证之后立马给分

解决方案 »

  1.   

    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; 如果是这样,哪里有错?
      

  2.   

    我的意思是通过SELECT 返回我指定的值,并不是返回第一列的值
      

  3.   

    select 1 from dual后面要加上分号";"
    即:select 1 from dual;Oracle的语法是这样的。
      

  4.   

    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
      

  5.   


    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加了报错
      

  6.   

    select 1  from dual
      

  7.   

    你的目的是什么
    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;
      

  8.   

    其实是这样的,我是想判断一张表有没有符合条件的记录,有就更新,没有就插入
    有个判断
    在调试阶段用select 1 ,select 2zhezhong zai MSSQL可以实现的方法来进行验证
    本来写 if exists(select count(*) from biao1) then
    select 1;
    elsif
    select 2;
    end if全是错误
      

  9.   

    其实是这样的,我是想判断一张表有没有符合条件的记录,有就更新,没有就插入
    有个判断
    在调试阶段用select 1 ,select 2这种在MSSQL可以实现的方法来进行验证
    本来写 if exists(select count(*) from biao1) then
    select 1;
    elsif
    select 2;
    end if全是错误
      

  10.   


    if exists(select count(*) from biao1) then
    select 1;
    else
    select 2;
    end if
      

  11.   


    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;
      

  12.   

    连这个都运行错误
    declare  
    v_count number;
     
    select count(*) into v_count from cb_t_dj_jgnsr2  ;
     dbms_output.put_line(v_count);我用的是PL/SQL工具 ora-06550 错误
      

  13.   

    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 ;
      

  14.   

    --块结构!!!
    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;