if not EXISTS(select * from table1 where a='2') 
insert into table1 values('2','2','2')这样的语句oracle不支持
if not EXISTS(select * from table1 where a='1') then 
insert into table1 values('2','2','2')
总说语句非法.
不知道怎么显示类似的功能
写判断表中是否由此语句.
如果没有就添加

解决方案 »

  1.   

    cnt number;
    select count(*) into cnt from table1 where a='1';if cnt > 0 then 
    insert into table1 values('2','2','2')
    end if;这样就可以拉!
      

  2.   

    这样就可以了insert into table1 select '2','2','2' from table1 where a='2' 
      

  3.   

    还有,要养成尽量在一个语句中完成一组业务逻辑,不要太过分散,也不要用太多数据库系统个性的东西,按我的写法,在SQLSERVER中也可以运行的。
      

  4.   

    insert into table1 values('2','2','2')
    where exists
    select 1 from table1 where a='2')
      

  5.   

    晕,楼上的,Insert into 还能接WHERE从句,高啊~~~~~~