Writing Text File From A Tabular Block In Oracle Forms
2016-12-25 20:04
711 查看
[align=left] The example given below for writing text file or CSV using Text_IO package from a tabular block in Oracle Forms. [/align] [align=justify] [/align] [align=justify]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:[/align] [align=justify] [/align]
[align=justify] [/align] [align=justify]You can also download this form from this link Job_History_Csv.fmb.[/align] [align=justify] [/align] [align=justify]Write the following When-Button-Pressed trigger code for the "Export To CSV" button:[/align] [align=justify] [/align] [align=justify]Declare[/align] [align=justify]out_file text_io.file_type;[/align] [align=justify]v_line varchar2(1000);[/align] [align=justify]begin[/align] [align=justify]out_file := text_io.fopen('C:\job_history.csv', 'w');[/align] [align=justify]go_block('job_history');[/align] [align=justify]-- move control to first record;[/align] [align=justify]first_record;[/align] [align=justify]loop[/align] [align=justify] v_line := :job_history.employee_id||','|| :job_history.start_date||','|| :job_history.end_date ||','||[/align] [align=justify] :job_history.job_id||','|| :job_history.department_id;[/align] [align=justify] text_io.put_line(out_file, v_line);[/align] [align=justify] -- move control to next record;[/align] [align=justify] if :system.last_record = 'TRUE' then[/align] [align=justify] exit;[/align] [align=justify] end if;[/align] [align=justify] next_record;[/align] [align=justify]end loop;[/align] [align=justify]text_io.fclose(out_file);[/align] [align=justify]-- again after completion move control to first record[/align] [align=justify]first_record;[/align] [align=justify]end;[/align] [align=justify][/align]
[align=justify] [/align] [align=justify]You can also download this form from this link Job_History_Csv.fmb.[/align] [align=justify] [/align] [align=justify]Write the following When-Button-Pressed trigger code for the "Export To CSV" button:[/align] [align=justify] [/align] [align=justify]Declare[/align] [align=justify]out_file text_io.file_type;[/align] [align=justify]v_line varchar2(1000);[/align] [align=justify]begin[/align] [align=justify]out_file := text_io.fopen('C:\job_history.csv', 'w');[/align] [align=justify]go_block('job_history');[/align] [align=justify]-- move control to first record;[/align] [align=justify]first_record;[/align] [align=justify]loop[/align] [align=justify] v_line := :job_history.employee_id||','|| :job_history.start_date||','|| :job_history.end_date ||','||[/align] [align=justify] :job_history.job_id||','|| :job_history.department_id;[/align] [align=justify] text_io.put_line(out_file, v_line);[/align] [align=justify] -- move control to next record;[/align] [align=justify] if :system.last_record = 'TRUE' then[/align] [align=justify] exit;[/align] [align=justify] end if;[/align] [align=justify] next_record;[/align] [align=justify]end loop;[/align] [align=justify]text_io.fclose(out_file);[/align] [align=justify]-- again after completion move control to first record[/align] [align=justify]first_record;[/align] [align=justify]end;[/align] [align=justify][/align]
相关文章推荐
- Copy Records From One Data Block To Another Data Block In Oracle Forms
- Populating Tabular Data Block Manually Using Cursor in Oracle Forms
- oracle 12C RAC启动实例时报ORA-00206: error in writing (block 1, # blocks 1) of control file错误处理
- Writing Text Files On The Client in Oracle Forms 10g
- Create Data Block Based On From Clause Query In Oracle Forms
- Moving From Top To Bottom in Detailed Block in Oracle Forms
- How To Commit Just One Data Block Changes In Oracle Forms
- Display certain line(s) from a text file in Linux.
- Create Stacked Canvas to Scroll Horizontal Tabular Data Blocks In Oracle Forms
- Determining Current Block and Current Item in Oracle Forms
- Example of Get_File_Name Function in Oracle Forms
- Create Stacked Canvas to Scroll Horizontal Tabular Data Blocks In Oracle Forms
- Creating Excel File in Oracle Forms
- Highlighting Text Item On Entry In Oracle Forms
- Using CLEAR_BLOCK To Prevent Save Confirmation Dialogs In Oracle Forms
- Freebie - Utility Form: Generate Excel Report From SQL Query In Oracle Forms 6i And 11g
- Get_File_Name Usage in Oracle Forms 6i
- Populate A List Item With Record Group In Oracle Forms Using Populate_List And Create_Group_From_Query Command
- Map Columns From Different Tables and Create Insert and Update Statements in Oracle Forms
- Shifting List Item Values From One List To Another In Oracle Forms