TEXT_IO code to write data to a flat file

PROCEDURE CREATE_FLAT_FILE IS
-- DESCRIPTION
--  Simple procedure to write to a text fille from a form
-- NOTES
--      Call this procedure from the WHEN-BBUTTON-PRESSED trigger
-- REQUIREMENTS
--  Must have access to local drives
--
--=============================================================================

   in_file   TEXT_IO.FILE_TYPE;
   linebuf   VARCHAR2(80);
   your_file VARCHAR2(50) := 'C:\TEMP\your_file.dat';
   text_line VARCHAR2(400);
BEGIN
    in_file := TEXT_IO.FOPEN(your_file, 'W');
    GO_BLOCK('YOUR_DATA_BLOCK');
    FIRST_RECORD;
    LOOP
 IF :your_checkbox = 'Y' THEN
  text_line := LPAD(:your_item1, 10, ' ')||
      LPAD(:your_item2, 20, ' ')||
           LPAD(:your_item3, 30, ' ')||
                LPAD(:your_item4, 50, ' ');
     --

          TEXT_IO.PUT_LINE(in_file, text_line);
      END IF;
          --
      exit when :SYSTEM.LAST_RECORD = 'TRUE';
      NEXT_RECORD;
    END LOOP;
    --
    TEXT_IO.FCLOSE(in_file);
EXCEPTION
     WHEN NO_DATA_FOUND THEN
      TEXT_IO.FCLOSE(in_file);
END;

Have a Oracle Question
Do you have an Oracle Question?

Oracle Books
Oracle Certification, Database Administration, SQL, Application, Programming Reference Books

Oracle Application
Oracle Application Hints and Tips

Oracle Home
Oracle Database, SQL, Application, Programming Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.