Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Export data in groups through pl/sql

$a!Feb 14 2020 — edited Feb 27 2020

Hi All,

I have a table sail_abc with 999 records and two columns.

create table sail_abc(c1 number, c2 varchar2(10));

insert into sail_abc

select rownum,dbms_random.string('x',10)  from dual

connect by level <1000

;

Note: the column c1 need not be unique though it is unique in the above example.

Now I want to export the data from this table into csv files with each csv file containing a maximum of 250 rows. So, since the above table contains 999 rows, 4 csv files should be generated. If it has 1200 rows, 5 files should be generated.

The columns in the csv files should be the columns of the table sail_abc exactly i.e., no rownum column etc should not be there in the files. Only c1 and c2 columns with a max. of 250 rows per csv.

Kindly help on the best way to achieve this.

Regards,

Sail

Comments
Post Details
Added on Feb 14 2020
12 comments
1,805 views