Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 







Oracle: write a file to to a client PC

Oracle Database Tips by Donald BurlesonAugust 4, 2015

Question: What are the choices for writing data from my Oracle server to my client PC?  I want to write alert log entries to my PC from the server.
Answer: Most folks use Javascript (or another client-side applet) for writing files to a client, and some people use Oracle's Javascript API for writing PC files.
If you want to use PL/SQL to write to client files Franck Pachot has this utility for writing trace files to a client PC:
column trace_name new_value trace_name heading "Following file is spooled in the current directory:"
 (select lower(instance_name) from v$instance)||'_ora_'||spid
   ||(select decode(value,null,'','_'||value) from v$parameter where name='tracefile_identifier')
   || '.trc'
 from v$process join v$session on (v$process.addr=v$session.paddr) join v$mystat using (sid) where rownum=1
set serveroutput on feedback off verify off termout off linesize 1024 trimspool on
spool &trace_name
 fd utl_file.file_type;
 line varchar2(1024);
 l_tracename VARCHAR2(512):='&trace_name';
 l_directory_path all_directories.directory_path%TYPE;
 l_directory_name all_directories.directory_name%TYPE;
 procedure t (msg in varchar2) is begin dbms_output.put_line(msg); end;
 /* use old parameter _cached_open_cursors to close all open cursors */
 for r in (select 1 from v$session_cursor_cache where count>0) loop
 end loop;
 /* get trace directory */
 select value into l_directory_path from v$parameter where name='user_dump_dest';
 /* get diretory name for it, or try to create it */
 select directory_name into l_directory_name from all_directories where directory_path = l_directory_path;
 when no_data_found then
    execute immediate 'create directory '||l_directory_name||' as '''||l_directory_path||'''';
   exception when others then
    raise_application_error(-20000,'You must CREATE DIRECTORY '||l_directory_name||' as ''' ||l_directory_path||'''; or be granted CREATE DIRECTORY.');
 /* opens the trace file */
 exception when others then
    raise_application_error(-20001,'Impossible to open file: '||l_tracename||' in '||l_directory_name||' ( '||l_directory_path||' )');
 /* read the trace file and prints it */
    when no_data_found then exit;
    when others then
     dbms_output.put_line('!!! error while reading file '||l_tracename||' in '||l_directory_name||' ( '||l_directory_path||' )');
 end loop;
 /* close and remove the file from the server */
 when others then
   raise_application_error(-20002,'Impossible to remove: '||l_tracename||' in '||l_directory_name||' ( '||l_directory_path||' )');
spool off
/* run tkprof */
host tkprof &trace_name &trace_name..txt



Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.