还有:
if '01' not in (select no from TABLE)
insert into TABLE ( No, Name, Type, Time)
values( '01', '123', 0,to_date('2006-03-02','yyyy-mm-dd'))这句在oracle下不能执行,如何解决呢
if '01' not in (select no from TABLE)
insert into TABLE ( No, Name, Type, Time)
values( '01', '123', 0,to_date('2006-03-02','yyyy-mm-dd'))这句在oracle下不能执行,如何解决呢
BEGIN
delete from TABLE where No = '01' ;
insert into TABLE ( No, Name, Type, Time)
values( '01', '123', 0,to_date('2006-03-02','yyyy-mm-dd'));
commit;
END;可以放在过程里,然后执行这个过程就可以了
insert into TABLE ( No, Name, Type, Time)
values( '01', '123', 0,to_date('2006-03-02','yyyy-mm-dd'));可以改为:update TABLE set name='123',type=0,time=to_date('2006-03-02','yyyy-mm-dd') where No = '01';
insert into TABLE ( No, Name, Type, Time)
values( '01', '123', 0,to_date('2006-03-02','yyyy-mm-dd'))--这个不是SQL语法,可以在plsql中实现。如果你的Oracle是9i及以上,可以用Merge来实现。merge into TABLE a
using (select '01' as no, '123' as name, 0 as type,to_date('2006-03-02','yyyy-mm-dd') as time from dual) b
when matched then
update ...
when not matched then
insert ..具体语法你自己查查吧
你可以打开 command windows 里面可以两句一起执行
用sqlplus联上数据库后用@d:\*.sql
这样就可以执行了
至於
if '01' not in (select no from TABLE)
insert into TABLE ( No, Name, Type, Time)
values( '01', '123', 0,to_date('2006-03-02','yyyy-mm-dd'))
這個SQL SERVER語法,放在Oracle中應該是:
if '01' not in (select no from TABLE) then
insert into TABLE ( No, Name, Type, Time)
values( '01', '123', 0,to_date('2006-03-02','yyyy-mm-dd'));
end if;