I have a select query in Oracle. I want to write query results in a txt file with CRLF (end of line) char. How can I do this?
2 Answers
You can use the utl_file package. Code fragment:
l_output utl_file.file_type;
l_output := utl_file.fopen( p_dir, p_filename, 'w' );
utl_file.put(l_output, 'Hello' );
...
utl_file.new_line( l_output );
utl_file.fflush( l_output );
utl_file.fclose( l_output );
First of all create a directory object (the p_dir parameter of the fopen) and grant it read and write privileges. See also at http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm