Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Add multiple records using UTL file

885842Oct 22 2014 — edited Oct 23 2014

Hi, i rarely deal with PLSQL so any help would be greatly appreciated.

I need to run a query that will select all occurances where the status column of a table

is equal to true and then write this out to a file on the operating system.This is fine if there is only one record but often there will be multiple records.

My UTL file script to deal with 1 record is as below:


DECLARE
L_HANDLER UTL_FILE.FILE_TYPE;
  vData           VARCHAR2(85);
 
BEGIN


  SELECT STATUS
    INTO vDATA
    FROM error_table;
  L_HANDLER := UTL_FILE.FOPEN('MYDIR', 'error.txt', 'W');
  UTL_FILE.PUTF(L_HANDLER, VDATA);
  UTL_FILE.FCLOSE(L_HANDLER);
END;


Many thanks,

Adam

This post has been answered by Frank Kulash on Oct 22 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 20 2014
Added on Oct 22 2014
16 comments
4,365 views