Write contents into UTL_FILE immediately after a single iteration

社会主义新天地 提交于 2019-12-06 03:23:15
Maheswaran Ravisankar

To write data to the file you should use the FFLUSH procedure. For instance:

OPEN my_cursor;
   LOOP
      FETCH my_cursor INTO my_details;
      EXIT WHEN sll_cur%NOTFOUND;
      -- Do processing
      utl_file.putf(logfile,'%s ',my_details);
      -- Call the FFLUSH proc here..And contents are available immediately.
      utl_file.FFLUSH(logfile); 
END LOOP;

From the documentation:

FFLUSH physically writes pending data to the file identified by the file handle. Normally, data being written to a file is buffered. The FFLUSH procedure forces the buffered data to be written to the file. The data must be terminated with a newline character.

Flushing is useful when the file must be read while still open. For example, debugging messages can be flushed to the file so that they can be read immediately.

There is more information on UTL_FILE in the Oracle docs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!