Home > database >  Oracle handle broken problem
Oracle handle broken problem

Time:09-29

1 1
2 2
3 3
4, 5
5 7
6 to 8
7 and 9
8 to 10
9 21
10 to 22
11 25
12 to 28
13 29
Test table, so I want to start from 5 to update into 4,5,6,7,8,,,,,,,
Select no
The from (the select rownum
The from TEST009 a, TEST009 b
Where rownum & lt; (select Max (no) from TEST009)
Minus
Select the no from TEST009)
Where no & gt; (select min (no) from TEST009) can the SQL query vacancies which number do can be put into 1 test table updates,2,3,4,5,6,7,8,,,,,,,

CodePudding user response:

To keep the original order is broken, compact,
There is a train of thought do not know is not suitable for your situation,
Sorted by the no, after all done no column to start with 1 assignment does not have to, is the updated data will be more, (can be judged, have broken do)
Anyway, as you say, behind a clear no to update all, see the business situation, what it feels not bad,
This is a good write

CodePudding user response:

Continuous field directly with this form of rownum update
 DECLARE 
C_ROW T_USER % ROWTYPE;
C_NO VARCHAR2 (2);
The BEGIN
FOR C_ROW IN (select ROWNUM, ID from T_USER order by ROWNUM) LOOP
The EXECUTE IMMEDIATE 'update SCOTT. T_USER set id=: where id=1:2'
USING C_ROW ROWNUM, C_ROW. ID;
END LOOP;
END;

CodePudding user response:

Directly according to the first column all assignment can again, with a loop
  • Related