Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Spooling output of a select statement to a file through stored

Re: Spooling output of a select statement to a file through stored

From: <DBarbour_at_austin.isd.tenet.edu>
Date: Wed, 29 Aug 2001 09:16:38 -0700
Message-ID: <F001.0037B432.20010829082120@fatcity.com>

Ranganath,

First you have to specify a place where Oracle may write the file. You do this by setting the UTL_DIR parameter in your init<SID>.ora file. Make sure that the Oracle user has write permission on the directory(ies) you specify. You'll need to bounce the DB to have this parameter take effect.

Your code will look something like this(this is for an NT Box):

CREATE or REPLACE .........
AS
  CURSOR XXX IS......         vocstu_report utl_file.file_type;

BEGIN         vocstu_report:= utl_file.fopen('F: \oracle\admin\reports','vocstu_report.txt','W');

(All your processing here)

                       utl_file.put_line(vocstu_report,
                                        RPAD(v_lastname,25,' ') ||
                                        RPAD(v_firstname,15,' ') ||
                                        RPAD(v_gender,6,' ') ||
                                        RPAD(v_grade,5,' ') ||
                                        RPAD(v_ethniccode,6,' ') ||
                                        RPAD(v_altid1,13,' ') ||
                                        RPAD(v_AGATInd,5,' ') ||
                                        RPAD(v_STXPInd,4,' '));


David A. Barbour
Oracle DBA, OCP
AISD
512-414-1002

                                                                                       
                          
                    "Ranganath K"                                                      
                          
                    <ranganathk_at_subex       To:     Multiple recipients of list 
ORACLE-L <ORACLE-L_at_fatcity.com>  
                    group.com>              cc:                                        
                          
                    Sent by:                Subject:     Spooling output of a select 
statement to a file through 
                    root_at_fatcity.com         stored procedure                          
                          
                                                                                       
                          
                                                                                       
                          
                    08/29/2001 06:00                                                   
                          
                    AM                                                                 
                          
                    Please respond to                                                  
                          
                    ORACLE-L                                                           
                          
                                                                                       
                          
                                                                                       
                          




Dear DBA Gurus,

           How do I spool output of a select statement to a file through stored
procedure. The stored procedure should take the directory and path of the file to be spooled to on the client machine. I know we can do this using UTL_FILE package. But I don't want to write to a file in Oracle Database server machine rather I want to write the output to a file in client machine. Please note that I want to do this through a Pl/Sql procedure or a
pl/sql program so that the procedure can be called from the front end which is Java/C++. How do I do this? Any help in this regard will be duly appreciated.

Thanks and Regards,

Ranganath

DISCLAIMER: This correspondence is confidential and intended for the named recipient(s) only. If you are not the named recipient and receive this correspondence in error, you must not copy, distribute or take any action in
reliance on it and you should delete it from your system and notify the sender immediately. Unless otherwise stated, any views or opinions expressed
are solely those of the author and do not represent those of Subex Systems Limited.

www.subexgroup.com

--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Ranganath K
  INET: ranganathk_at_subexgroup.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L

(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: INET: DBarbour_at_austin.isd.tenet.edu Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).
Received on Wed Aug 29 2001 - 11:16:38 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US