I am running oracle and have a query which pulls some results from the database. I would like to write the results as a text file. How would I go about doing this?
M
Use UTL_FILE in combination with CREATE DIRECTORY for ease of mapping a directory path with a name (it does not create the actual directory just a reference to it so ensure it is created first)
example
create directory logfile as 'd:\logfile'; -- must have priv to do this
declare
vFile utl_file.file_type;
begin
vFile := utl_file.fopen(logfile ,'syslog','w'); -- w is write. This returns file handle
utl_file.put(vFile,'Start Logfile'); -- note use of file handle vFile
utl_file.fclose(vFile); -- note use of file handle vFile
end;