-
I think I've had too much holiday food. My brain won't think so I need some help with this problem.
I have a table. It has 100 rows of data.
I select 25 rows based on a field "A" value.
I change the values in two fields ("A" and "B") of these 25 rows.
I then add these 25 rows back to the table so the table now has 125 rows of data (100 old records + 25 new records).
Any suggestions?
-
so what is the problem???
-
I cannot figure out how to write a script file to accomplish this task. I've tried to dynamically create the new table and then using a cursor, loop through the table and update the fields. And then insert all the values from the new table into to the old table. This does not work because the new table defined in the cursor does not exist yet.
-
Originally posted by ocp2b
I think I've had too much holiday food. My brain won't think so I need some help with this problem.
I have a table. It has 100 rows of data.
I select 25 rows based on a field "A" value.
I change the values in two fields ("A" and "B") of these 25 rows.
I then add these 25 rows back to the table so the table now has 125 rows of data (100 old records + 25 new records).
Any suggestions?
Helo friend,
You can find a script for this in the book by Thompson Kite( man who answers asktom) (published by Wrox.) the book may be Oracle scripts or Oracle complete reference
all the best
-
try somethin like this:
declare
inc number:=1;
eno number;
cursor c1 is
select empno, ename, sal from emp
where empno > 7500;
begin
for c1rec in c1 loop
eno:=c1rec.empno + inc;
inc:=inc+1;
insert into emp (empno, ename, sal)
values (eno, c1rec.ename, c1rec.sal);
end loop;
exception
when others then
dbms_output.put_line('exception');
end;
Cheers!
OraKid.
-
Try Like this
INSERT INTO YOURTABLE
SELECT 'A' CHANGEDVALUEA,'B' CHANGEDVALUEB
FROM YOURTABLE WHERE ROWNUM<=25
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|