create or replace Directory FILEWRITE as 'X:\';
? grant read,write on Directory FILEWRITE to public;?
? declare
? ? fileID utl_file.file_type;
? begin
? ? fileid := utl_file.fopen('FILEWRITE', 'xxx.xx', 'w');
? ? for REC in (select * from X.x) loop
? ? ? begin
? ? ? ? utl_file.put_line(fileid, Rec.Bcpcmd);
? ? ? end;
? ? end loop;
? ? utl_file.fclose(fileID);
? ? if utl_file.is_open(fileID) then
? ? ? utl_file.fclose(fileID);
? ? end if;
? end;
/
exit;?