Spool file creating

hi i am running a unix loop and in that creating a sql statement. now i want to spool the result to a file . but the problem is the spool file should have time as the name. loop runs after every 2 mins.
while [ true ];
do
sudo su - BATPBL<<!
sqlplus hr/hr<<!
spool /ankur/ank_XXXX #XXXX should be the time
select * from guard_usr order by guard_usr_id;
spool off
sleep 9
done
Please help

You could implement in your spool project something like this :
[oracle@g5 ~]$ sqlplus fas_admin
SQL*Plus: Release 11.1.0.6.0 - Production on Mon May 18 11:27:25 2009
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> !export DATE=$(date +"%m_%_d_%y %H:%M:%S")
SQL> spool datefile.txt$DATE
SQL> select me from you;
select me from you
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> spool off;
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@g5 ~]$ ls -l datefile.txt*
-rw-r--r-- 1 oracle oinstall 137 2009-05-18 11:28 datefile.txt05_18_09 11:23:39
[oracle@g5 ~]$also you can visit http://en.wikipedia.org/wiki/Date_(Unix)

Similar Messages

  • Creating spool file for  Mass printing of smartforms

    Hi all
    My requirement is Mass printing of Development Plans,
    In this case is i need to select all the smartforms depending upon the selection screen data.& i need to pass all the smartforms to newly created spool file..
    how should I use TSP01 & Function Module 'GET_PRINT_PARAMETERS' for this smartform spool.
    so can any body explain me in detail..
    How to create spool ID, ?
    how to create spool file in this case..??
    How to pass smartform data to that new spool file../??
    Any sample codes for this…./??
    Thanx in advance,
    Regards,
    Kalam A.

    Check the links -
    Re: How to create a spool?
    How to create a spool request
    Regards,
    Amit
    Reward all helpful replies.

  • Spool to cvs file creates blank rows

    Hello, I am trying to create a spool file to a csv file. i am able to create the csv file successfully, but every 14 rows there is a blank row. This will cause a problem since we will have another application reading this file and most likely error out when it reaches the blank row.
    I have a batch fiile that is calling a sql file that runs the script that produces the spool. We are using oracle 10g, release 10.2.0.4.0
    I have tried different options with the spool but nothing seems to help. here is an example of my result
    1-1011S6
    1-101HGX
    1-1027Y
    1-108FAP
    1-108FDP
    1-10BJB
    1-10CIIU
    1-10K6QD
    1-10NNY5
    1-10P5G9
    1-10PTI5
    1-10RAY
    1-112DI
    1-115PEP
    1-118PAO
    1-12KWI
    1-142UB
    1-14CJ3
    1-14CM7
    1-14D2R
    1-14LJU
    1-14LRN
    1-14RWV
    1-14WEW
    1-15239
    1-15276
    1-152YQ
    1-1539N
    1-153NO
    1-1541D
    any ideas would be great.
    Thanks in advance

    This is becuase of the pagesize in SQLPLUS which by default is 14.
    Make sure it is larger than the maximum numbe of elements you are expecting (or) Zero.
    http://download-uk.oracle.com/docs/cd/B19306_01/olap.102/b14346/dml_x_obj012.htm
    sql> select rownum, object_id from user_objects
      2  where rownum < 20;
        ROWNUM  OBJECT_ID
             1      52136
             2      52098
             3      52124
             4      52099
             5      52100
             6      52118
             7      52120
             8      52139
             9      52123
            10      52101
            11      52102
        ROWNUM  OBJECT_ID
            12      52103
            13      52127
            14      52104
            15      52075
            16      52076
            17      52143
            18      52115
            19      52137
    19 rows selected.
    sql> set pagesize 50;
    sql> /
        ROWNUM  OBJECT_ID
             1      52136
             2      52098
             3      52124
             4      52099
             5      52100
             6      52118
             7      52120
             8      52139
             9      52123
            10      52101
            11      52102
            12      52103
            13      52127
            14      52104
            15      52075
            16      52076
            17      52143
            18      52115
            19      52137
    19 rows selected.
    sql> set pagesize 0;
    sql> /
             1      52136
             2      52098
             3      52124
             4      52099
             5      52100
             6      52118
             7      52120
             8      52139
             9      52123
            10      52101
            11      52102
            12      52103
            13      52127
            14      52104
            15      52075
            16      52076
            17      52143
            18      52115
            19      52137
    19 rows selected.

  • Create  multiple spool files

    Hi All,
    Is it possible to create a mutiple spool files which contains different data from the abap program at once.
    Please let me know your thoughts.
    Thanks & Regards
    Santhosh

    If you execute the program in BACKGROUND, it will automatically create spool.
    ONLINE EXECUTION: you need to write your statements to be taken to spool within NEW_PAGE PRINT ON & OFF.
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
           EXPORTING
                COVER_PAGE          = WC_X
                DESTINATION            = <Printer Name>
                EXPIRATION              = 2
                IMMEDIATELY           = SPACE
                LAYOUT                   = 'X_65_255'
                LINE_COUNT             = 65
                LINE_SIZE                = 255
                LIST_NAME              = <LIST_NAME>
                LIST_TEXT              = <SPOOL_TITLE>
                *NEW_LIST_ID            = WC_X*    "New Spool
                NO_DIALOG              = WC_X
                SAP_COVER_PAGE  = WC_X
           IMPORTING
                OUT_PARAMETERS    = WA_PRINT_PARA
                VALID                          = WS_VALID
           EXCEPTIONS
                ARCHIVE_INFO_NOT_FOUND = 1
                INVALID_PRINT_PARAMS   = 2
                INVALID_ARCHIVE_PARAMS = 3
                OTHERS                 = 4.
      IF WS_VALID <> SPACE AND SY-SUBRC EQ 0.
        NEW-PAGE PRINT ON PARAMETERS WA_PRINT_PARA NO DIALOG.
        PERFORM DISPLAY_REPORT. "Write Statements
        NEW-PAGE PRINT OFF.
    endif.
    Reward if useful.

  • Create spool file

    hi @all,
    I search a way to create a spool file in a htmldb application (intranet) which writes a xls.file on a default place of the client filesystem.
    I dont't know whether it works with pl/sql or javascript.
    any ideas?

    What about calling your job from dbms jobs?

  • Can't create spool file

    Hi,
    I've problems in creating spool file. I've some PL-SQL scripts, running monthly with sqlplus on Windows 2000, that have always generated spool file using the statements "spool filename.log".
    Two days ago, I run this scripts and I noticed that they didn't create the log file, but nothing has been changed.
    I noticed that changing the script with "spool c:\filename.log" the spool file is correctly generated.
    I run the script using sqlplus user/pwd@db @c:\script.sql and in the body of the script there is:
    whenever oserror exit SQL.OSCODE rollback
    whenever sqlerror exit SQL.SQLCODE rollback
    spool faXXXXX_X.log
    Set autocommit off timing on echo on feedback on termout on serveroutput on
    set escape ^
    DECLARE
    Why "spool filename.log" suddenly stop to work? There is some enviroment variable who determine the default directory of spooled file?

    My PATH variable has a lot of directories, some of them are "C:\oracle\ora81\bin;C:\Program Files\Oracle\jre\1.1.7\bin;C:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\orant\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;"
    I make a "search" for the spooled file in all the directories of the hard disk; the problem is that the spooled file has not been created but the SQL script terminated succesfully. What's the possible reason?

  • 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>

  • How to get the number of rows written to the header of the spool file.

    Hi
    I need to create a header line for the spool file .
    the header line should include fixed length values .
    The header should include the number of records found in the table with a maximum begin date (begin_date is the column of the table)
    To get the header in the spool file , i wrote a select query has :-
    --SPOOL 'C:\Documents and Settings\abc\Desktop\output.TXT'
    select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000') ||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) ||
    rpad(' ',76,' ')
    from dad.school
    group by sysdate;
    SPOOL OFF
    which gets me all the rows in the table , but i only want the rows with the latest school_begin_date .
    how can i achieve that ...
    I know that a subquery should be written in the from clause to get the number of rows found with a maximum school_begin_date.
    select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000') ||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) ||
    rpad(' ',76,' ')
    from dad.school where
    select rownum from dad.school
    where school_begin_date = max(school_begin_date) ;
    the error i get is
    ORA-00934: group function is not allowed here
    I NEED HELP ..IN GETTING THE ROWNUM JUST FOR THE LATEST BEGIN_DATE ?
    PLS HELP ME IN WRITING THE QUERY .
    THANKS IN ADVANCE .

    Try this:
    select 'W'||to_char(sysdate,'MM/DD/YYYYMi:HH:SS')||lpad(max(rownum),9,'000000000')||'R'||max(to_char(school_from_date,'MM/DD/YYYY')) || rpad(' ',76,' ')
      from dad.school
    where school_begin_date = (select max(school_begin_date)
                                  from dad.school);

  • Can I download a spool file from ALV payroll recon report in Fixed Ascii?

    We have a process that imports the spool files from our various nightly payroll recon reports but have recently upgraded to ECC 6.0 and the ALV formatted report does not appear to create a fixed format spool file - the width of the columns changes from spool to spool based on the contents.
    Does anyone know how to accomplish our need?
    Thanks,
    DeWayne

    Does the printer show up in the Windows Printers folder?  We've used PDF995 or Cute pdfwriter for years.  All of these create virtual windows printers.  When you print to them, a dialog box pops up asking for the filename for the pdf.  If you have Activex calls to Excel in order to open a file, you should be able to make ActiveX calls to print it to a print driver such as this.  I don't know if any of these drives have a way to bypass the filename dialog box.  That may take some research and experimentation.  I don't know where the postscript file comes into play in the scenario you are describing.

  • Creation of Spool File with Triggers

    Hi,
    I have created an OnUpdate trigger using the Essbase Console. I am using a calculation script to change the value of an account that is being used in the trigger. The trigger doesnot craete a spool file. Can anyone help me with it.

    Are you sure that the data value that should change did change?
    Here I am plugging Glenn's presentation twice in like five minutes. Check out this (unrelated) thread -- it explains how to get to his Kaleidoscope presentation.
    How to use a substitution variable in a load rule?
    FWIW, this part of the presentation was really good (it was all good, but I particularly enjoyed this bit).
    Regards,
    Cameron Lackpour

  • Data in spool file does not match output.

    This is a strange issue, and I'm not even sure it's a problem in SAP, but I don't know where else to ask and haven't found anything like it online:
    We create pick lists on dot matrix printers.  Occasionally, the output is missing a digit or character - for example in the middle of the delivery number.  If delivery number is 81234567, the dot matrix output might be 8123467.  The SAP spool file is not missing any data.  And the paper dot matrix output is never skewed nor looks like it has jammed or "hiccuped".  There is no space where the missing piece of data should be - it's all run together nice and neat.  It occurs on different bits of data (sometimes, delivery#, name, batch, etc.), and it occurs on different printers at different sites.  So far, it has always been only one digit or character missing every time it occurs.  Reprint from the spool and it comes out fine.
    So, SAP data is correct, and it occurs on different printers.  Maybe it's a network issue?  A printer buffer issue - but it happens on two different units, and that would be a weird coincidence.  I really have no ides.  Has anyone ever experienced anything like this?
    Thanks,
    Anke

    Hello -
    Difficult to answer accurately here as no access to spool data on the affected system and exact methods used. But, perhaps if you can print the RAW (OTF) data to a fileprinter and send that as a .txt file to the printer hardware vendor they could investigate why certain characters do not print.
    Regards.

  • Putting date and time in a spool file name for output

    I have bee trying to find this answer but don't know where to look: I want to take all or part of the date and/or time to create a unique filename on the fly for a spool file. Can someone point me in the right direction? I am using SQL*Plus.

    undefine curDateCol
    column curDateCol noprint new_value curDateCol
    select to_char(sysdate,'YYYYMMDDHH24MISS') curDateCol from dual;
    undefine fileName
    define fileName=/myFileName_&&curDateCol..csv
    prompt creating &&fileName ...
    set echo off
    set termout off
    set showmode off
    spool &&fileNamehth

  • Need Spool file 255 characters for background HR Reports into Excel

    We have been looking for a solution for problem this for more than 2 years now.
    Problem:
    1.     Requirement is to run large HR reports – either standard or with Ad Hoc Query in background mode in a company with more than 50,000 employees.
    2.     Nobody wants printed reports these days.  We want to save the forests. Customers prefer to be emailed an Excel file so they can do further data analysis, filtering, pivot tables etc.
    3.     Reports are running OK in foreground for smaller sections of the organisation, where you send the output to Excel from ALV, or save as a local file in spreadsheet format.
    4.     But large reports for entire company are awkward, tie up your PCs resources, and complex reports accessing many tables can timeout before completion.
    5.     So scheduling these reports to run in background would be the ideal solution.
    6.     However when we access the report output from SP02, we find that most reports (say with more than 13 or so fields) have an output wider than 255 characters and the output of the spool file wraps to the next line in Excel.  It is very tricky to then parse the data back into one row for each employee.  And you have a problem if you output is for 50,000 or so employees, because then you file is 100,000 rows and will not load completely into Excel – limit problem of 65,536 characters.
    7.     We simply want a spool file that does not wrap the data to the next line after 255 characters.
    8.     But how to explain this simple requirement to some technical people. It seems a lot of posts on SDN think we always want to print a spool file.  NO – remember the forests!
    Possible Solutions:
    I see a lot of posts here that refer to OSS note 186603, but they don’t mention the target for the output of the spool is to import into an Excel File (i.e. spreadsheet format).  Just search for 186603 or ” Spool request with more than 255 columns”.  There is also a reference to OSS note 313566.  I am not sure if these will work?
    I have also seen the suggestions that you need to define a customer printer format that does not wrap the output after 255 characters (create a new format type in transaction SPAD).
    Can anyone help us!
    John McKee

    Hi,
    Can you please check whether you can use:
    CONSTANTS C_LF TYPE X VALUE '0A'.
    CONSTANTS C_CR TYPE X VALUE '0D'.
    Regards,
    Lakshmi.

  • Prevent Occurence of list header and page breaks in spool file of ALV Grid

    Prevent Occurence of list header and page breaks in spool file of ALV Grid  Display.
    When we run the ALV in background and create spool request then:
    Spool file output is coming like this.
    Column1 Column2 Column3 Column4
    data        data        data       data
    data        data        data       data
    data        data        data       data
    Column1 Column2 Column3 Column4
    data        data        data       data
    data        data        data       data
    data        data        data       data
    But the required is like this
    Column1 Column2 Column3 Column4
    data        data        data       data
    data        data        data       data
    data        data        data       data
    data        data        data       data
    data        data        data       data
    data        data        data       data
    Please suggest a posible answer

    Hello all,
    if you have not yet solved this on your own, here is my solution: use a format type that has 60000 lines per page for your spool output device.
    It all depends on the format type that was used for creating the spool output.
    By default (in our system), we have 65 lines per page. And after each page the column headings of the ALV will appear.
    What i did:
    create a new format type via transaction SPAD->full administration->device types->format types (copy an existing one)
    change"Number of Rows" to 60000 or something applicable
    edit the device type of your output device (e.g. LOCL) to contain the newly created format type (via SPAD; Button "Formats" in device type maintenance).
    That's it! Be sure to use this format type for your output device in the "Background Print Parameters" window (-> Button "Properties").
    Regards
    Daniel Klein
    All other parameters you discussed before didn't do it. All ALV-Settings will be overwritten by the output device settings and its print properties.

  • 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

Maybe you are looking for

  • Kernel Panic at boot but works in safe mode

    I am getting a Kernel Panic at boot on the grey screen If I boot safe mode it works fine. Whats the procedure to find whats cause the problem? Is there a log file I should look at or what is the best way to figure this out

  • HELP!!! iphone 3gs stuck in recovery mode

    I tried doing the latest iphone system software update and the **** thing got stuck in recovery mode! The 291 MB update downloads fine and it made a backup and then i assume it removed the old software and started installing the new software. It goes

  • Canon Rebel xsi/450D: Intervalometer app for ios?

    Hi, Any good recommndation for intervalometer app on ios (preferably free) and what kind of cable do i need to connect with Rebel xsi/450D?  For the purpose of creating Timelapse. Thanks

  • What is Report Painter in Abap ?

    What is Report Painter in Abap ? How we can write a simple report through report painter . It's Tcode , How to proceed ? I developed several report through ABAP , but i have no clue about Report Painter . What is advantage to using it . Plz give some

  • Weblog and Groups

    I have the weblog up and running on our 10.4.8 server. I can log in to weblog with my short username and password. So now I would like to create a group weblog so multiple users can make entries to a single blog. In WGM I created a group called "Tech