how to read and write a given number of records

Hi there,

I would like if someone can help me out of the following problem:

I am working with a database with hundreds of huge tables. Now, i have to put the entire set of records in another rbales (just making a copy, bu not the same as: Create TABLE as select * from another table)

I want to read a table of 1.000.000(1 million records)in the next way:

1) read the firts 10.000 records in the table,

2) write them away in another table

3) remove the already read 10.000 records

4) read next 10.000

and so on until all records have been read.



I hope someone can help me.

I tried it out with 'CURSOR' but it did not work proper.

Help me please


Comments

  • You can copy the record using



    insert into table (select * from tab2);



    This is the sample pro, which reads 3 records at a time inserts into table then again reads 3 records and so on...this is written for emp table.Make it as per our requirement.





    declare

    cursor c1 is select empno from emp;

    num number;

    a number;

    begin

    open c1;

    fetch c1 into num;

    loop

    exit when c1%notfound;



    for a in 1..3

    loop

    insert into emp1(empno) values(num);

    fetch c1 into num;

    exit when c1%notfound;

    end loop;



    end loop;

    end;








Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories