日期:2014-05-17 浏览次数:21046 次
begin for i in 1..100 loop update product set product_info='商品描述测试'||i where rownum = i; dbms_output.put_line('商品描述测试'||i); end loop; end;
CREATE TABLE T58 ( ID NUMBER(4), ProductInfo VARCHAR2(20) ); INSERT INTO T58 VALUES(1, NULL); INSERT INTO T58 VALUES(2, NULL); INSERT INTO T58 VALUES(3, NULL); INSERT INTO T58 VALUES(4, NULL); INSERT INTO T58 VALUES(5, NULL);
------解决方案--------------------
oracle中rownum不能跨过rownum=1去查rownum=2的,可以这样用:
select t1 from (select t.*,t.rownum as no from product t)t1 where t1.no=2