|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Anyone know how I can loop through a table, inserting an incrementing value into a newly added column so I can set this column to be not null?
Thanks! |
|
#2
|
|||
|
|||
|
Code:
DECLARE
cnt NUMBER(8):=0;
myrow ROWID:=NULL;
CURSOR mycursor IS
SELECT ROWID
FROM MYTABLE
WHERE new_column is NULL
AND ROWNUM=1;
BEGIN
LOOP
OPEN mycursor;
FETCH mycursor INTO myrow;
EXIT WHEN mycursor%NOTFOUND;
CLOSE mycursor;
UPDATE mytable
SET new_column=cnt
WHERE ROWID=myrow;
cnt:=cnt+1;
END LOOP;
CLOSE mycursor;
COMMIT;
END;
/
|
|
#3
|
||||
|
||||
|
Wow, thanks!
![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Filling values in a table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|