The example given below for writing text file or CSV using Text_IO package from a tabular block in Oracle Forms.
Suppose there is a tabular grid data block "Job_History" in your forms and you want to write a CSV on click of a button by reading whole block from top to bottom. The following is the demo screen shot:
You can also download this form from this link Job_History_Csv.fmb.
Write the following When-Button-Pressed trigger code for the "Export To CSV" button:
out_file := text_io.fopen('C:\job_history.csv', 'w');
-- move control to first record;
v_line := :job_history.employee_id||','|| :job_history.start_date||','|| :job_history.end_date ||','||
-- move control to next record;
if :system.last_record = 'TRUE' then
-- again after completion move control to first record
Oracle Forms Recipes eBookDownload