我用的是Oracle9i,我试过了update table1 set col1=0,col2=0,col3=0 where col4>0 不可以。 我也看过Oracle的书。书上是这样写的: update table1 set (col1,col2,col3)=(select col1,col2,col3 from table2); 没有说要更新为常数该怎么办。
9i居然有这样的问题? update table1 set (col1,col2,col3)=(select 0,0,0 from table1 where col4>0); 这样试试
update table1 set col1=0,col2=0,col3=0 where col4>0 在oracle9i的错误信息是什么:ora-?????
没有错误,这句可以在SQL*Plus WorkSheet中执行,可在存储过程中就不行.
update table1 set col1=0,col2=0,col3=0 where col4>0 这样写在oracle9i中执行应该没有问题,看看是不是有别的错误,或者 你把执行时的错误贴上来
用一个主健如id来标识 update table1 a set (col1,col2,col3)=(select 0,0,0 from table1 b where b.col4>0 and a.id=b.id); 或者: update table1 set (col1,col2,col3)=(select 0,0,0 from table1 where a.id=b.id) where a.col4>0 ;
------------------------------------------------------------
COL2
--------------------------------------------------
COL3
--------------------------------------------------
COL4
--------------------------------------------------
1
1
1
5SQL> update test1 set col1='1',col2='2',col3='3' where col4>'4';
SQL> select * from test1;COL1
------------------------------------------------------------
COL2
--------------------------------------------------
COL3
--------------------------------------------------
COL4
--------------------------------------------------
1
2
3
5SQL> desc test1
COL1 VARCHAR2(60)
COL2 VARCHAR2(50)
COL3 VARCHAR2(50)
COL4 VARCHAR2(50)
不可以。
我也看过Oracle的书。书上是这样写的:
update table1 set (col1,col2,col3)=(select col1,col2,col3 from table2);
没有说要更新为常数该怎么办。
update table1 set (col1,col2,col3)=(select 0,0,0 from table1 where col4>0);
这样试试
update table1 set col1=0,col2=0,col3=0 where col4>0
这样写在oracle9i中执行应该没有问题,看看是不是有别的错误,或者
你把执行时的错误贴上来
update table1 a set (col1,col2,col3)=(select 0,0,0 from table1 b where b.col4>0 and a.id=b.id);
或者:
update table1 set (col1,col2,col3)=(select 0,0,0 from table1 where a.id=b.id) where a.col4>0 ;