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:declareOut_file Text_io.file_type;V_line VARCHAR2 (1000); BeginOut_file: = Text_io.fopen (' C:\job_history.csv ', ' W ');Go_block (' job_history ');-Move control to first record;First_record;Loop V_line: =: job_history.employee_id| | ', ' | | : job_history.start_date| | ', ' | | : job_history.end_date | | ', ' | | : job_history.job_id| | ', ' | | : job_history.department_id; Text_io.put_line (Out_file, v_line); -Move control to next record; If:system.last_record = ' TRUE ' Then Exit End If; Next_record;End Loop;Text_io.fclose (Out_file);--Again after completion move control to first recordFirst_record; End
Writing Text File from A tabular Block in Oracle Forms