您的位置:首页 > 数据库 > Oracle

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]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: