Oracle Spool File

Hi All,
I am new to this SPOOLING of oracle Sql data to a file.I am in need of formatting a file.That format looks like...
Date: 05/17/2006 SOI DIFFERENCE REPORT Page 1
Latest SOI File Generated : 1:01AM ON 2006/05/18
CUSIP DESC SYMBOL
table data
Can any one help in formatting this spool file.
[email protected]

Perhaps the linesize is too short?

Similar Messages

  • Please Help in ORACLE SPOOL File

    Hello All,
    I made oracle Spool file.Generally i m calling a FUNCTION which return a REFCURSOR.
    ----Package Spec------------------------
    CREATE OR REPLACE PACKAGE Axspointrpt IS
    TYPE return_cur IS REF CURSOR ;
    -- # Updates to the SOI and associated CARMA user ids
    FUNCTION F_UPDATION_USERID_RPT RETURN return_cur ;
    END Axspointrpt;
    ----Package Body------------------------
    CREATE OR REPLACE PACKAGE BODY Axspointrpt IS
    FUNCTION F_UPDATION_USERID_RPT
    RETURN return_cur IS
    VCur return_cur;
    BEGIN
    OPEN VCur FOR
    SELECT
    ID_SCTY,ID_SYMBOL,NM_SHORT,S.DT_MNT_LST,S.ID_MNT_LST,LTRIM(RTRIM(CARMA_FINAL.F_Getusername(S.ID_MNT_LST))) USERNAME,DECODE(IN_DELETED,'Y','YES','N','NO') ACTION
    FROM SOI_MASTER S,APP_USER A
    WHERE S.ID_MNT_LST=A.ID_MNT_LST;
    RETURN VCur;
    EXCEPTION
    WHEN OTHERS THEN
    IF (VCur%isOpen) THEN
    CLOSE VCur;
    END IF;
    END F_UPDATION_USERID_RPT ;
    -----------callRPT.sql ------------------
    SET MARKUP HTML ON SPOOL ON HEAD "<TITLE>SQL*Plus Report</title> -"
    SET ECHO OFF
    SET PAUSE OFF
    SET VERIFY OFF
    SET FEEDBACK OFF
    SET HEADING ON
    SET LINESIZE 150
    set PAGESIZE 85
    SET TRIMSPOOL ON PAGESIZE 50
    SPOOL D:\Avinash\employee.htm
    select Axspointrpt.F_UPDATION_USERID_RPT from DUAL;
    clear breaks
    TTITLE OFF
    SPOOL OFF
    SET MARKUP HTML OFF
    SET ECHO ON
    When i run this SQL file then i am getting the procedure name as well as CURSOR STATEMENT along with the table data.I want get Hide the procedure namd,and cursor statement.Please help in this.
    Regards,
    [email protected]

    Hi Avinash,
    Try this:
    create or replace package dump_refcursor_test is
    type return_cur is ref cursor;
    function get_data return return_cur;
    end dump_refcursor_test;
    create or replace package body dump_refcursor_test is
    function get_data return return_cur
    is
    l_cur return_cur;
    begin
    open l_cur for select 'qwerty' from dual;
    return l_cur;
    end get_data;
    end dump_refcursor_test;
    Create a file called spool.sql put it in c:\. Put his in the file:
    SET NEWPAGE 0
    SET SPACE 0
    SET LINESIZE 80
    SET PAGESIZE 0
    SET ECHO OFF
    SET FEEDBACK OFF
    SET HEADING OFF
    SET MARKUP HTML OFF SPOOL OFF
    set sqlprompt "".
    var res refcursor;
    exec :res:= dump_refcursor_test.get_data;
    spool c:\spool_output
    print res
    spool off
    Now go to sql*plus and type this:
    @c:\spool.sql
    This will give you a file with only the data, here "qwerty"
    Regards Pete

  • How to fit the data in Oracle SPOOL FIle

    Hi all,
    Word_rapped ,Formatted etc etc dif every thing ...
    Some columns data arent fitting in to the page.What I want to fit the ouput of query in to one page (A4).
    is there any SPOOL command to fit

    I'a affraid that you have to use more than one command to do it,
    set pagesize 72 --- set how many lines will be on a page
    set linesize 80 ---- set howmany character will be in one line
    column columnName fromat a20 -- sets that column with columnName will be 20 character wide
    set heading on | off - set heading on and off
    You have to experiment a little bit , you can find more formating comands in documentation
    Best Regards
    Krystian Zieja / mob

  • Changing the file extension in Oracle Spool

    Hi All,
    I need to spool some specific data for the entire year. I'm using date parameter for selecting the month wise data.
    In single parameter I’m retrieving file_name,From_date and to_date.
    But by default spool file is getting generated with .lst extension, Please let me know if any one has any idea for changing the file extension in spool, Below is code for your reference.
    SET heading off;
    SET termout off;
    DEFINE L_DATE=&P_DATE; --here I’m passing Month and year value e.g. ‘JAN-09’
    DEFINE L_FILENAME='Invoice_Header_&L_DATE';
    SPOOL d:/&L_FILENAME;
    SELECT invoice_id || invoice_date
      FROM apps.ap_invoices_all
    WHERE invoice_date >= '01-&L_DATE'
      AND invoice_date <= last_day('01-&L_DATE')
    AND ROWNUM <= 2;
    SPOOL off;   Thanks in Advance,
    Arun

    Thanks Saubhik for replying.
    I got the solution at
    http://www.dbforums.com/oracle/886693-spool-text-file.html
    Regards,
    Arun
    Edited by: user2988171 on Oct 19, 2010 4:04 PM

  • SQL and Spool File: low performance  (Oracle 8)

    Hi,
    I've got some difficulties with the spool function: it works very slowly when I have to write on a file.
    In details, a shell script starts the PL/SQL procedure, which starts the spool function that produces a file.dat .
    Oracle solves the query and sends out the data immediately. This with 850 million of records for a 20gb final file. The total time to write this file is 8 hours.
    May it be a solutions with could to improve this file writing procedure, trying not to use the spool function, like a C program which could work on the memory? In this way it could take fewer time.
    Thank you for your suggestions and solutions.
    A

    Oracle RDBMS does not write to the spool file. The client does (SQL*Plus in this case).
    SQL*Plus uses standard kernel calls.
    To open/create the file and write data to it:
    - open call with flags O_WRONLY|O_CREAT|O_TRUNC (see open (C System Call) - Code Wiki)
    - write call to file descriptor (see write (C System Call) - Code Wiki)
    These are standard calls supported by all modern kernels (Unix, Linux, Windows, OS/X, etc). The performance of which is entirely dependant on how fast the kernel can service the call. Which in turn is dependant on the speed of the file system on which these calls operate.
    Speeding up a spool type process typically means using async I/O (called overlap I/O in the Windows kernel). The approach being to fetch the next set of data from the database cursor, while writing the previous fetch's data to spool file, at the same time.
    Of course, better and faster hardware can also improve the performance of the I/O subsystem and make such a spool process faster.

  • Extraction of oracle pkg and pkg bodies into spool file??

    Hi,
    I need to extract all packages and its bodies into spool file. can you give me script or guide how to do this.. i have more than 200 packages.. need to create spool file for each package. great thanks for help.
    /mr
    Edit/Delete Message

    From 10g, DBMS_METADATA is designed for ! :)
    [http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_metada.htm#i1019414]
    Edited by: Leo Anderson on 1 sept. 2008 14:22

  • Spool file problem,Can't see the query in output file.

    Hello ,
    I am facing a very old school kind of problem .....about spool file ....
    The scenario -
    I have made a script by name DB_Status_checkup.sql which i want to fire on the database to check the database status. In this script their are many queries regarding the data dictionary views to know about the database. It consist of nearly 25-30 different select queries..
    The problem is i want to make a spool file of the output of that query....i want to see the SQL query & the output below in the spool file, so it will be easy for me to judge the result. But i can't see the SQL query , i can only see the output , & in so many queries it all gets jumbled up....even i can't understand where the next output starts ...
    Sample of my SQL Script ....
    clear buffer
    spool D:\DB_status.txt
    /*To check the database startup time*/
    Select to_char(startup_time, 'HH24:MI DD-MON-YY') "Startup time"
    from v$instance
    .........next query n so on....
    spool off;
    In the output pf the spool file at D:\db_status.txt..
    Startup time
    08:25 16-JUL-10It shows only the output of the query in the spool file not the query,
    What should i do to get the SQL query as well as the output of that query just below it in the spool file ???
    Please suggest if you have anymore ideas , regarding this .....
    ORACLE 10g R2
    Windows Server 2008
    Thanks in advance ...

    Why don't you just use database control, instead of re-inventing the wheel?
    Apart from that, SQL*Plus has it's own reference manual, which you apparently refuse to read.
    The answer to your quiz/doc question is
    set echo on
    Sybrand Bakker
    Senior Oracle DBA

  • How to spool file to where start script file located

    I'm writing a sqlplus script, eg. runMe.sql, which is going to run in customer env, will generate some data files eg. result.csv.
    By specify location such as 'spool /certain/path/on/disk/result.csv', I can spool to any path I want. However, my concern is  below:
    1. We gets many customers and the script might be run under different location.
    2. I don't know where customer would save the script, furthermore, I don't want customer to input location manually every time.
    3. Generally, customer would run the script something like "sqlplus username/password@sid @/certain/path/on/disk/runMe.sql". They don't want to pass any parameter at run time.
    4. I wanna spool file to "/certain/path/on/disk" automatically, as a result, result.csv file would appear under same path with runMe.sql.
    5. I tried "spool ./result.csv" but it navigate to where sqlplus session is running.
    6. Also tried &0 etc, but make no sense.
    Can anyone tell me how to obtain start running script file path in sqlplus script(runMe.sql) ? Just like access command parameters under Linux.
    $0 is the name of the command
    $1 first parameter
    $2 second parameter
    $3 third parameter etc. etc
    $# total number of parameters
    $@ all the parameters will be listed
    Thanks in advance.

    Are you looking for SQLPATH ?
    A good and clear example by Paul @ https://forums.oracle.com/message/3727891
    In this way your customer has to set one environment variable SQLPATH=/location/of/script/file/where/they/put/your/runMe.sql and just say :
    spool %sqlpath%\result.csv
    in your runMe.sql.  So, runMe.sql and result.csv will be on SQLPATH location.
    Regards
    Girish Sharma

  • Date and time in spool file name

    Hi,
    can anyone show me how i can write the code below so that the spool file will automatically take the system time and date?
    thanks again.
    set term off;
    set echo off;
    set heading off;
    set linesize 1500;
    set pagesize 9999;
    set feedback off;
    spool /home/oracle/ATM_Upload/files/CRD000119MMDDYYHHMISS.DAT;
    SELECT rec_ind||source_type||bbdsa_code||seq_num||dt_ti_ext||ver_num
    as atm_header
    FROM atm_dc_hd;
    spool off;

    Hi,
    I do something similar to this in a file called ed.sql which I use in SQL*Plus to give me a history of SQL*Plus buffers in separate files which follow the naming convention $DATABASE_$SID_$TIMESTAMP.sql. I use it from SQL*Plus when editing, rather than typing "ed" I type "@ed" and it does the naming for me:
    -- Turn off terminal output
    set termout off
    -- Save current buffer to a temp file
    save tmp.txt replace
    -- Set editfile name to $DATABASE_$SID_$TIMESTAMP.sql
    column fname new_value fname
    column sid new_value sid
    select trim(sid) sid
    from v$mystat
    where rownum = 1;
    select global_name||'_&sid'||'_'||to_char(sysdate, 'YYYYMMDDHH24MISS')||'.sql' fname
    from global_name;
    set editfile '&fname'
    -- Retrieve our initial buffer
    get tmp.txt
    -- Turn terminal output back on
    set termout on
    -- Fire up the editor
    edYou could probably adapt this in the following way for your needs:
    column fname new_value fname
    select 'CRD000119'||to_char(sysdate, 'MMDDYYHH24MISS')||'.dat' fname
    from dual;
    spool '&fname'I don't know how you get the 'CRD' part of the filename but you may be able to generate that too using the above as a guide.
    cheers,
    Anthony

  • Display error messages in spool file

    I am running the below code (ssn_run.sql) using sqlplus 10.2.0.1.0 on my windows XP professional client PC.
    The database is a Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit running on Solaris
    There are 3 insert statements and 3 update statements. I have mentioned 'show sqlcode' after each of these
    dml statements. Hence currently, I look at the spool file, analyze before I confirm that every sqlcode is a 0.
    Now, is there a way to alter this code so that it can show if any of the sqlcode is not 0(if there is a problem) somewhere
    at the end of the spool file ? Or even if I am able to just indicate if there is any ORA- error anywhere in the code and can indicate this somewhere at the end of the spool file, that is fine as well.
    --The code
    accept input_ssn prompt 'Enter SSN :'
    set feedback on
    set echo on
    set term on
    set heading on
    set pagesize 0
    set linesize 10000
    set verify on
    undefne sdate input_ssn
    col sdate new_value sdate
    col input_ssn new_value input_ssn
    select to_char(sysdate,'YYYYMMDD') sdate from dual;
    spool C:\PERSON_DATA_&&sdate._&&input_ssn..TXT
    select 'REPORT GENERATED ON : '||SYSDATE FROM DUAL;
    INSERT INTO ADDRESS_OLD SELECT * FROM ADDRESS WHERE ADDRESSID IN(SELECT ADDRESSID FROM PERSON_ADDRESS
    WHERE PERSONID IN(SELECT PERSONID FROM PERSON WHERE SIN = '&&input_ssn'));
    show sqlcode;
    commit;
    INSERT INTO PERSON_OLD
    (PERSONID, TITLE, FNAME, MNAME, LNAME, ACFM, SIN, UNAME, AKANAME, DCFM,
    IROWID, SUFFIX, PTYPE, OLD_SSN)
    SELECT PERSONID, TITLE, FNAME, MNAME, LNAME, ACFM, SIN, UNAME,
    AKANAME, SIN FROM PERSON WHERE SIN = '&&input_ssn';
    show sqlcode;
    commit;
    INSERT INTO MEMBER_OLD
    (CLNT, MKEY, PERSONID, MEMNO, OLD_MEMNO)
    SELECT CLNT, MKEY, PERSONID, MEMNO,MEMNO
    FROM MEMBER WHERE PERSONID IN(SELECT PERSONID FROM PERSON WHERE SIN = '&&input_ssn');
    show sqlcode;
    commit;
    UPDATE ADDRESS SET STREET1 = 'ROCKY RD',STREET2=NULL,CITY = 'ALABASTER',PROVINCE = 'AL',POSTAL='34216',
    PHONE1='1111111111' WHERE ADDRESSID IN(SELECT ADDRESSID FROM PERSON_ADDRESS WHERE PERSONID
    IN(SELECT PERSONID FROM PERSON WHERE SIN = '&&input_ssn'));
    show sqlcode;
    commit;
    UPDATE PERSON SET FNAME = TRANSLATE(SIN,'0123456789','ACEGIKMOQS'),
    LNAME = TRANSLATE(SIN,'0123456789','SQOMKIGECA'),
    UNAME = TRANSLATE(SIN,'0123456789','ACEGIKMOQS')||' '||TRANSLATE(SIN,'0123456789','SQOMKIGECA'),
    AKANAME=NULL WHERE SIN = '&&input_ssn';
    show sqlcode;
    commit;
    UPDATE MEMBER SET MEMNO = MKEY WHERE PERSONID IN(SELECT PERSONID FROM PERSON WHERE SIN = '&&input_ssn');
    show sqlcode;
    commit;
    spool off;
    set term on
    set feedback on
    set HEADING on
    set verify on
    --End of code
    Thanks

    QUESTION:
    As in the code above, I am inputting a value while running the script. And I am spooling all of it to a spool file. I also get the old and new values , like
    old 7: client_54.PERSON_OLD WHERE OLD_SSN = '&&input_ssn'))
    new 7: client_54.PERSON_OLD WHERE OLD_SSN = '123456774'))
    old 11: WHERE PERSONID IN(SELECT PERSONID FROM PERSON_OLD WHERE OLD_SSN = '&&input_ss
    new 11: WHERE PERSONID IN(SELECT PERSONID FROM PERSON_OLD WHERE OLD_SSN = '123456774'
    Is there a way I can get rid of these in the spool file?

  • Add comments to a spool file

    Is there any way to add comments to a spool file? Below is the typical output I have. I'd like to add comments to let me know what table has been updated or analyzed.
    Table altered.
    708662 rows updated.
    Commit complete.
    Index created.
    Table analyzed.
    Table altered.
    Index created.
    Table analyzed.
    Commit complete.

    Perhaps you are looking for the PROMPT command?
    http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a90842/ch13.htm#1010446

  • Creating a spool file with date/time appended to file name

    In Oracle Sql*Plus, I want to spool out a file, with the date-time stamp as part of the file name. Any idea how to do this?
    Here's what I have right now:
    SQL>
    set serveroutput on size 200000;
    rem
    rem $OFSA is a UNIX alias so sql plus is talking to UNIX
    rem
    spool $OFSA/logs/OFSAP/common_coa_id.log;
    prompt 'Enter date in mmddyyyy format, without quotes';
    exec upd_common_coa_id_driver ('&date_mmddyyyy');
    spool off;
    As an example, I'd like to have a file with this name: common_coa_id083002.log
    Thanks.

    In SQL*Plus this is what you can do to get the current date/time as part of the spool file:
    ============================================================================================
    SQL> column tm new_value file_time noprint
    SQL> select to_char(sysdate, 'YYYYMMDD') tm from dual ;
    1 row selected.
    SQL> prompt &file_time
    20020816
    SQL> spool C:\Temp\logfile_id&file_time..log
    . /* put your code here */
    . /* it will go to a file called C:\Temp\logfile_id20020816.log */
    SQL> spool off
    SQL>

  • Seek help to format spool file from SQL*PLUS

    I am running a Unix shell script to call a Oracle 11g SQL script from a Oracle database. In this SQL script, I need to connect to many different remote databases to select data, then sool these records as one big text file to a directory. Then email the file to related Group users. In the spool file, there is a line on the top of each page like this:
    DUMMY
    DB_NAME
    I know this is caused by connect to remote database in SQL*PLUS. My connection string is like this:
    Conn system/password@Oracle_SID
    How can I remove these lines or how to skip these lines into spool file? Please advise. Thanks in advnce. Wish all of you Happy New Year!!!

    Hi,
    It sounds like you have some kind of formatting (such as SQL*Plus TTITLE) producing the output you don't want. If that's the case, temporarily stopping the spooling might not help you. Find out what is causing the output that you don't want. You say that you know it is caused by the CONNECT statements, but it must be more than that. I've written scripts with CONNECT statements that don't have anything like what you reported at the top of each page; in fact, they don't even have pages: the output is one continuous stream. Find out what's putting the unwanted output there, and that will be a big clue as to how you can stop it.
    You say that you know the unwanted titles are there because of the CONNECT statements. If so, use database links instead of CONNECT. You don't have to use dbms_scheduler or utl_file; just eliminate the CONNECT statements. (I'm not saying that there's anything wrong with dbms_scheduler or utl_file; you should definitely investigate those tools. I'm just saying that using database links is independent of them.)
    What would happen if you did all your connecting to different databases at the OS level? Can you write a shell script that connects to each database in turn, and runs a SQL*Plus script in each one. Each SQL*Plus script would have a SPOOL or SPOOL ... APPEND command, or maybe you could build the SPOOL into a LOGIN.SQL script.

  • Spool file contains spool off; statement and a / in it .how to remove these

    Hi ,
    I am new to using forums.
    I am a basic beginner user of oracle .
    I need to spool the output of 2 select queries into a file.
    I could achieve it.
    But the file also contains ,
    SPOOL OFF;
    in it . How to avoid these in the file.
    Any help is appreciated .
    thanks

    user11768287 wrote:
    Hi
    I checkout and created a .sql file .
    But the spool file , contains an empty line after every record is printed. These are the heading i am using.
    SET HEADING OFF
    SET ECHO OFF
    SET TERMOUT OFF
    SET VERIFY OFF
    SET FEEDBACK OFF
    The spool file starts with a blank line followed by the record and then blank line after every record .
    What to do to get all records one after the other without blank lines in between the records in the spool file.
    In addition to Toni's mention of PAGESIZE and TRIMSPOOL, look at LINESIZE. Also, what are you using to view the spooled file? Are you sure you aren't just seeing line wrap within that application - like Notepad?
    Thanks ...

  • Remove extra blank rows in ORACLE SPOOLING

    I am trying to spool a table result to a .dat file.
    The problem is the output spool file has 3 rows after each row with a column having its row data split as 3 for every enter key in the data.
    Eg:
    Original data as in DB
    A B C
    1 1 ABC DEF GH
    2 1 DEF GHI JK
    SPOOL FILE O/P
    A | B | C |
    1 | 1 | ABC |
         | |DEF |
         | |GH |
    2 | 1 | DEF |
         | | GHI |
         | | JK |
    Thanks,
    Dheepan

    Dheepan wrote:
    I am trying to spool a table result to a .dat file.
    The problem is the output spool file has 3 rows after each row with a column having its row data split as 3 for every enter key in the data.
    Eg:
    Original data as in DB
    A B C
    1 1 ABC DEF GH
    2 1 DEF GHI JK
    SPOOL FILE O/P
    A | B | C |
    1 | 1 | ABC |
         | |DEF |
         | |GH |
    2 | 1 | DEF |
         | | GHI |
         | | JK |
    Thanks,
    Dheepancan you post script?
    BTW, have you included SET TRIMSPOOL ON ?
    When you have moved your question, Close that thread ORACLE SPOOLING extra blank rows
    Edited by: CKPT on Mar 24, 2012 10:07 PM

Maybe you are looking for

  • HR ABAP: LOOP AT SCREEN: Multiple Fields Disabling.

    Experts, Am a new member in the world of SAP ABAP! Need ur advice regarding. Have coded following for disabling a field in PBO based on subtypes.     IF p9235-subty = GC_AICTD.       IF screen-name = 'P9235-ZZ_RC_MDE'.         screen-active = 0.     

  • How to connect cuts in final cut pro

    I would like to re-connect cuts that I have made in my project, how do I go about doing that? TIA D

  • N96 video ringtone problem

    I bougth the n95 yesterday and I already did the 11.0 update. There is a problem with the ringtones though. If I set a video ringtone in my general profile and someone from my contacts call me, it rings with the default ringtone and does not used the

  • Team Calendar in ESS

    Hi , I have set up all most everything in backend, but unable to view calendar in the ESS tab. There is an error thown up " 500 Internal Server Error". Can you advise what is gone wrong? Regards Joe

  • Newbie Help with SWF

    Howdy, I am working on a website with just plain html/css at the moment. I was provided a SWF intro for the splash page from a developer who designed the page. I have implemented the object and embed code so the SWF loads. Problem is that I want to c