Output a varchar2 field to a spool file.

I have a varchar2 field in the database which has returns in it. So it has 3 lines of output. When I spool this to s file, that record spans across 3 lines as opposed to 1 line/record.
I tried using replace(field,'^M','') to get the output but that gives me only the first line of the field.......
ANY IDEAS ?????

Have you checked the width of varchar2 data type.else modify it to long and try it.

Similar Messages

  • Adding field names to spool file?

    I'd love to add the field names and "AS" labels as a header row to a spool file...here's a few lines from the spool script:
    --SET heading on
    --SET echo off
    --SET space 0
    SET trimspool on
    set feedback off
    set termout off
    set heading off
    set pagesize 0
    set linesize 2000
    SPOOL C:\spools\Prod\files\test\profile_2003.txt
    SELECT
    a.ZIP
    ||'|'||a.STATE
    ||'|'||a.COUNTY
    ||'|'||a.ZIPNAME
    ||'|'||a.STATENAME
    ||'|'||a.COUNTYNAME
    ||'|'||a.POPCY
    ||'|'||a.SEXCYMAL-- AS POPMALE
    ||'|'||a.SEXCYFEM-- AS POPFEMALE
    ||'|'||a.AGECYMED-- AS MEDIANAGE
    something to do with the SET parameters perhaps?
    this will be a huge help to me if someone can point me in the right direction...
    Thanks!
    - Pete

    Try:
    SPOOL C:\spools\Prod\files\test\profile_2003.txt
    SELECT
         'ZIP'           ||'|'||
         'STATE'               ||'|'||
         'COUNTY'               ||'|'||
         'ZIPNAME'      ||'|'||
         'STATENAME'      ||'|'||
         'COUNTYNAME'      ||'|'||
         'POPCY'               ||'|'||
         'POPMALE'              ||'|'||
         'POPFEMALE'     ||'|'||
         'MEDIANAGE'
    FROM
         dual
    SELECT
         a.ZIP           ||'|'||
         a.STATE               ||'|'||
         a.COUNTY               ||'|'||
         a.ZIPNAME      ||'|'||
         a.STATENAME      ||'|'||
         a.COUNTYNAME      ||'|'||
         a.POPCY               ||'|'||
         a.SEXCYMAL     ||'|'||
         a.SEXCYFEM     ||'|'||
         a.AGECYMED
    FROM
         your_table a
    SPOOL OFF     

  • Copy the existing output rom Z program into a  spool file

    Hi all,
    There's a Zprogram if its run in foreground a list gets created .(as per req, i want this list in a spool file and not the below spool file)
    If this program is run in background a spool file gets created.
    I dont want the existing spool result instaed i want the other result which is generated via se38  as a spool file.
    Pls suggest.
    One more question is i don't see any code in program where the existing spool file is written.similarly i have checked another program earlier where i dont see the code where exactly spool file gets created ,moreover no sub programs in that too.
    Thanks for the help.

    Hi ,
    I don't want existing spool data.
    But i need the list in foreground run to be saved as the spool file.
    will commenting out  the statements which writes to current spool file(yet to identify this part of the code) be a good option
    Or,
    If i can create another spool file ,how to do it.
    basically how to create 2 spool file in the same program,1 spool is already getting created..
    Thanks,

  • 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

  • Spool file error - Buffer Overflow

    I've a sql script that is running from a.sql file. The script fetches almost 9 million data as a result of the query. Main problem is related to spool file generation. It is saying buffer overflow. But, when i write that query from sql prompts it is running within 2 mins and completes the task within 15 mins.
    I've written -
    set serveroutput on size ######
    But, still it is not working. Total application is freeze whenever i want to run it. Tell me any suggestion if u have.
    Satyaki.

    i guess what you are more concerned with is the output produced by your query (the spool file).
    you need not to see what is displayed on the screen all you need is open up the spool file to
    check for those data in there.
    to suppress the output from the screen and still generates spool file. use the SET TERMOUT option.
    e.g.
    -- code for a producing a sample spool file
    spool r:\sample_spool.txt;
    select * from emp;
    spool off;
    at the SQL*Plus command line:
    SQL> @r:\sample_spool.sql;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7566 JONES      MANAGER         7839 02-APR-81       2975       1000         20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7788 SCOTT      ANALYST         7566 09-DEC-82       3000                    20
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 12-JAN-83       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.
    SQL> -- the above example displays the output on the screen
    SQL> -- now we want to turn it off by using the SET TERMOUT option
    SQL> SQL> set termout off;
    SQL> @r:\sample_spool.sql;
    SQL>
    after executing the script sample_spool.sql it does not display output from the screen which
    we want to avoid the buffer overflow error. and still produce the spool file:
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO                                  
          7566 JONES      MANAGER         7839 02-APR-81       2975       1000         20                                  
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20                                  
          7839 KING       PRESIDENT            17-NOV-81       5000                    10                                  
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30                                  
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10                                  
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20                                  
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30                                  
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30                                  
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30                                  
          7788 SCOTT      ANALYST         7566 09-DEC-82       3000                    20                                  
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30                                  
          7876 ADAMS      CLERK           7788 12-JAN-83       1100                    20                                  
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30                                  
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10                                  
    14 rows selected.

  • Not getting correct output for smatform in spool file

    Hi All,
    I am using smartform to print some letter. In the smartform under main window I have put some layouts. For each layout I am displaying some particular fields in spool file. In the line editor I have given some conitions (if -elseif-else) to display different fields.
    <b>My code in line editor is like:</b>
    /: if <condition1>
    &var1&
    /: elseif <condition2>
    &var2&
    /: else
    &var3&
    So it should display diffent output according to the conditions. But when I am trying to execute form, its showing var1, var2 & var3 all in spool file.
    Does it  means there is no effect of if conition??
    Could u please help me in solving this issue.
    Thanks in advance.
    Regards,
    Vijay

    Why don't u try at Program lines instead of editor.

  • How to spool out put of multiple scripts and get a single spool file output

    Hi,
    I have one master script that calls three other scripts. The three scripts each produce their own spool files. But I would like to have the master script also produce one single output (in addition to the three indiviual output I mean). How to do that? Can you please help.
    Following are the scripts:
    --m.sql (master script)
    spool c:\m.log
    @1.sql
    @2.sql
    @3.sql
    spool off
    --1.sql
    spool c:\1.log
    insert into test values(1);
    commit;
    spool off
    --2.sql
    spool c:\2.log
    insert into test values(2);
    commit;
    spool off
    spool c:\3.log
    insert into test values(3);
    commit;
    spool off
    --table used
    SQL> desc test
    Name                                      Null?    Type
    A                                                  NUMBERWhen I run the above script m.sql it does produce the other 3 log files (1.log,2.log etc) but m.log (which is master log file which should have output of each of the three calling script) is empty file with 0 byte!
    Thanks
    Edited by: orausern on May 1, 2011 3:17 AM

    I have one master script that calls three other scripts. The three scripts each produce their own spool files. But I would like to have the master script also produce one single output (in addition to the three indiviual output I mean). How to do that? Can you please help. Not sure if that's possible directly with sqlplus spool option
    When you spool to a different file in a single session, sqlplus stops writing to earlier spool file and redirects the output to the file specified in last spool command.
    at the end of the script, however, below may help
    host type c:\1.log >> c:\m.log
    host type c:\2.log >> c:\m.log
    host type c:\3.log >> c:\m.log

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

  • How to download alv grid output(with field catalog) into excel file format

    Hi all,
    How to download alv grid output(with field catalogs) into excel file format and same file has to download to application server.
    Please help.
    Regards,
    Satya.

    Hi,
    On list where alv is displayed, select export icon( green color -> ),select spread sheet.
    This will display records in Excel sheet.

  • How to set an output spool file size

    hi experts,
    now i am run a output spool file transaction, if i run in a small volumn, it is only give one output spool file which is ok for me, but if in a full volumn run, it will give a multiple output spool file which is not what i want, so i was wondering if the output spool file size can be set somewhere and only give me only one output spool file when in the full volum run.
    thanks.

    Hi,
    Have you tried transaction SP01O.
    Regards,
    Atish

  • Output to spool file only

    Hi,
    I don't want the output of the spool file to be written to a log file while executing the script. My script looks like this,
    #/bin/ksh
    sqlplus test/test 1>>/test/abc.log 2>>/test/abc.log <<EOF
    set termout off
    set feedback off
    set flush off
    spool /test/test.dat
    select 'a' || 'b'|| 'c' from dual;
    spool off
    disconnect;
    exit;
    EOF!
    I want the output to be written only into the spooled file. now it writes to both the log file and spool file. how can i avoid it from writting to the log file(1>>/test/abc.log). pl help

    Actually. Why do you want to write to both anyway?
    You are using the general unix format to write to a file so why do you need another file?

  • 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

  • Output different with the spool file

    Hi friends,
    I have using this Tcode : S_ALR_87012301 to print GL account balances.
    once executed, the system display correct information.
    but once printed, in spool file, instead of showing the name of the company , the system displayed the environment e.g Production. If we try to print in DEV, the system will display Development.
    Your advice is highly appreciated.

    Celtic Mom
    Welcome to the Apple user to user discussion forums
    While I was organizing my photos, I realized there are about 30 or so photos that have the same exact file name as another photo. Example: There are two IMG_1243.jpg, but they are different pictures. They were taken at different times, even different years. I have used more than one camera to import photos. I have changed the name of one of the photos in the Title area in the information section of iPhoto. When I try to put the newly named photo into a folder that has the other IMG_1243, I get a message that says" An older item named "IMG_1243" already exists. Do you want to replace it with the newer one you are moving?"
    I want to have both IMG_1243.jpg photos in the same folder. How can I do this? Also, I have a few thousand pictures, so how can I tell exactly how many photos have the same file name as another photo?
    It sounds like you are using the finder inside the iPhoto library - do not do that - you will corrupt your library and lose the edits, keywords, etc that you have
    iPhoto does not care about duplicate file names - it handles it fine
    changing the title of a photo does not affect the file name - although when you export the photo you can use the title for the file name as an option
    What are you doing and what do you want to accomplish?
    Remember do not ever make any changes in the iPhoto library using the finder or any other program
    LN

  • Converting RPAD output from VARCHAR2 to CHAR

    I am trying to create a 1000-character fixed-width file using SQL*Plus. The query consists of 3 fields with a pad of 25 characters each, with the remaining 925 characters as filler using spaces. Using RPAD I can insert spaces between the three field values, but because the RPAD function uses VARCHAR2 to return the result it is not recognizing the ~945 filler spaces I need at the end of each row.
    Is there a way to convert the output of RPAD to a CHAR data type in the query itself? Maybe something equivalent to the CONVERT function in t-SQL?
    Query I'm using:
    Select RPAD(Col1, 25, ' ') || RPAD(Col2, 25, ' ') || RPAD(Col3, 950, ' ') From Table1;
    Thanks,
    Matt

    Hi,
    Welcome to the forum!
    You can ihave trailing spaces (950 of them if you want, no problem) in a VARCHAR2 column. I suspect your font-end tool is not displaying them.
    The SQL*Plus commands
    SET  TRIM        OFF
    SET  TRIMSPOOOL  OFFshould guarantee that trailing spaces are displayed in screen- and SPOOL file output, respectively.
    Also, make sure your lines are long enough:
    SET  LINESIZE    1000If you still have a problem, post a complete test script (including all the SQL*PLus formatting commands you use) as well as a query. (Something using dual or scottt.dept should illustrate the problem adequately).

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

Maybe you are looking for

  • Camera kit accessory not supported

    Hi, I have an iPad 1 and a camera connection kit that works fine. It was working up to a week ago on a new ipad2. I updated my mac to 10.7.1 and synced my ipad2 for the first time in a while before going on a trip. During the trip I tried to use the

  • Streaming Large Files to Response OutputStream consumes plenty of memory

    When we write large file's (> 100 MB) binary content to the Servlet Response OutputStream using the write method, it consumes plenty of Heap Memory on the server (Weblogic 7). The Heap does'nt come down after writing to the outputstream, it stays hig

  • Userexit at Save for IW51/IW52 - Service Notification

    Hi, Does anybody know any userexit  or BADI that will be triggered when the user clicks SAVE for transaction IW51 or IW52 to create/change a service notification? The userexits that I found so far do not seem to be triggered at the SAVE. IWO10026 IWO

  • Is oracle user created by default during installation of OEL 5

    i want to know that is oracle user and its groups already created by default during installation of OEL 5.5 ??

  • VirtualBox won't capture mouse [SOLVED]

    So it becomes impossible to install a system (i like to test distros and what better than VB for that, you can read the install docs as you go) because you can't use the mouse to select the various menu options during the install. That's odd because