Can one read/write files from PL/SQL?

Please contact revion.com first, so we can enter directory into oracle config.

Included in Oracle 7.3 is an UTL_FILE package that can read and write operating system files. The directory you intend writing to has to be in your INIT.ORA file (see UTL_FILE_DIR=... parameter). Before Oracle 7.3 the only means of writing a file was to use DBMS_OUTPUT with the SQL*Plus SPOOL command.

Copy this example to get started:

DECLARE
  fileHandler UTL_FILE.FILE_TYPE;
BEGIN
  fileHandler := UTL_FILE.FOPEN('/tmp', 'myfile', 'w');
  UTL_FILE.PUTF(fileHandler, 'Look ma, I''m writing to a file!!!n');
  UTL_FILE.FCLOSE(fileHandler);
EXCEPTION
  WHEN utl_file.invalid_path THEN
     raise_application_error(-20000, 'ERROR: Invalid path for file or path not in INIT.ORA.');
END;
/

  • 0 أعضاء وجدوا هذه المقالة مفيدة
هل كانت المقالة مفيدة ؟

مقالات مشابهة

What is PL/SQL and what is it used for?

PL/SQL is Oracle's Procedural Language extension to SQL. PL/SQL's language syntax, structure and...

How do I send e-mail messages from PL/SQL?

Please follow this greate example: below: (http://www.orafaq.com/scripts/plsql/smtp.txt) rem...

How to resolve: ORA-29248: an unrecognized WRL was used to open a wallet

When using Wallet for paypal or Google checkout the following error may occur: ORA-29248: an...

Send mail with UTL_MAIL

How to send mail with with UTL_MAIL 1. first you need to contact us to get acl opened. Please...