FORMATTING SQLPLUS OUTPUT

I am running a shell script
shell script
#!/bin/sh
sqlplus /nolog <<EOF>/ora01/file1
CONNECT aaa/bbb@abc
select table_name from user_tables;
exit
EOF
output
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Sep 13 17:01:53 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> Connected.
SQL> SQL> SQL> SQL> SQL>
COUNTRIES
REGIONS
JOBS
JOB_HISTORY
EMPLOYEES
DEPARTMENTS
LOCATIONS
SQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
desired result
COUNTRIES
REGIONS
JOBS
JOB_HISTORY
EMPLOYEES
DEPARTMENTS
LOCATIONS
how can i format my sqlplus output so that my desired result is as above.
Thanks!

Yes, this seem to work, however, only if connect is done not from within sqlplus but from the shell prompt.
~ >cat s.sh
#!/bin/sh
sqlplus -s scott/tiger <<EOF
set term off feed off head off pages 0
select table_name from user_tables;
exit
EOF
~ >./s.sh
DEPT
EMP
BONUS
SALGRADE
SCHEME_CBFOWF1
DR$SCHEME_CBFOWF1_IDX$I
DR$SCHEME_CBFOWF1_IDX$R
PROVATAB1
DR$PROVAINDEX1$I
DR$PROVAINDEX1$R
CREATE$JAVA$LOB$TABLE
X
SYS_IOT_OVER_57950
SYS_IOT_OVER_57953
JAVA$OPTIONS
PROVA1
DR$PROVAINDEX1$N
DR$PROVAINDEX1$K
DR$SCHEME_CBFOWF1_IDX$N
DR$SCHEME_CBFOWF1_IDX$KBest regards
Maxim

Similar Messages

  • How to format sqlplus output

    In previous OTN Forum format we used {code} to format sqlplus output , how to do in this version ?

    Click on "Use Advanced Editor".
    Highlight your code.
    Click on the symbol >>
    Select Syntax Highlighting
    Select SQL...output looks like below:
    select sysdate from dual;

  • Sqlplus set statement:format the output without specifying every col length

    Hi ppl,
    i am writing below query inside a shell script. Is there any way to format the output of sqlplus without providing the name of all the columns that we are going to output. for example, in below code i have specified the column width of the columns i want to output. but if the number of columns is large (or when we want to do a select * from...) then it becomes tedious to write all of them. Is there any way i can define display length all the columns to be of same size.. or at least all the number columns of one size, char columns of one size etc...
    sqlplus -sa/passwd@db_name << EOF
    SET ECHO ON;
    SET HEADING ON;
    COLUMN USERNAME FORMAT A20;
    COLUMN USER_ID FORMAT A20;
    COLUMN PASSWORD FORMAT A20;
    spool filename.txt
    some qry... ;
    exit
    EOFThanks
    Edited by: KnockTurnAll on 25 Oct, 2010 10:41 PM
    Edited by: KnockTurnAll on 26-Oct-2010 04:25

    My SQL*Plus is a bit rusty, but I don't think you can for characters. You can set NUMWIDTH for a default size for numeric columns.
    You could write a small bit of SQL to generate the required column definitions. You could even hit ALL_TAB_COLUMNS to generate a generic 'set every column width' file and run it as a separate sql script in your main script. Not sure if there is an upper limit on the number of Columns you can define.
    Back in the day when we did everything with SQL*Plus scripts, we had a standard columns file that we called in all our scripts, just for this purpose.
    Carl

  • Need Formatted html output from Xalan

    We use xalan xslt processor to convert
    xml document to html. Everything works
    fine, except the output is unformatted html.
    (ie. several HTML elements appear on the
    same line. Some lines are longer than 1000
    characters). This happens inspite of me
    specifying the HTML elements in different
    lines in the xsl.
    I would like to know if there is any way, I can generate formatted html output.
    Thanks

    have u tried
    <xsl:output indent="yes"/>
    in your stylesheet?
    ravi <[email protected]> wrote:
    We use xalan xslt processor to convert
    xml document to html. Everything works
    fine, except the output is unformatted html.
    (ie. several HTML elements appear on the
    same line. Some lines are longer than 1000
    characters). This happens inspite of me
    specifying the HTML elements in different
    lines in the xsl.
    I would like to know if there is any way, I can generate formatted html
    output.
    Thanks

  • Formatting printer output for dotmatrix printer

    Hi Experts,
    i'm trying to format the output of the EPSON LQ-870 dot matrix printer to print the output in the paper size height 280 mm & width 210 mm.The device type i used for my output device is EPESCP2.For the first page the header and line items are coming correctly.But for the second page onwards, there is some space is coming between each line items.In third page,the header is coming little bit down from the required location.My page size is little bit less than the normal A4 size.How to rectify this?
    Points will be rewarded if helpful.......
    Thanks in advance.

    Hello,
    I created a condition table '550 - Shipping point/plant'. Then I created an access sequence 'ZSH1' and assigned this condition table 550 to it.
    In the output determination procedure, the procedure 'V10000 - Header output' has the condition type PL02 - BOL: Single Delivery assigned to it.
    The assignments look like:
    Step       Counter         Cond Type
    10               1                LD00     Delivery Note
    20               2                PL00     Packing list
    30               3                PL01     Planning Slip
    40               4                PL02     BOL: Single Delivery
    In Assign output procedures, the entry corresponding to delivery type 'LF' is:
    Del Type                O/P procedure                       O/P Type
    LF Delivery                    V10000  Header Output             LD00Delivery Note
    When I try to enter a new condition record using VV21, it does not show up this key combination 'Shipping point/Plant'.
    Can someone tell me if I am missing some customization?
    Thanks,
    Rugmani
    Edited by: Rugmani Rajan on Oct 22, 2008 3:06 PM

  • Formatting the output (currency with decimals)

    hi all,
          i want to format the output of the currency field. Right now it displays the exact value like say 23 or 43.5 etc. But my requirement is i need it to display in a standard format as 23.00 , 43.50 , 565.00 etc. i,e if there is no decimals then it should be filled with zero's.
    I have gone through some of the threads which speaks of formatting the output if it is a value node. But here i have directly bounded the table to a model node.
    Domian level datatype of the field is Currency in R/3. After model import in dictionary it is showing as decimal.
    How can i achieve this?I Appreciate if someone can help me on this.
    Regards,
    G Nid

    hi,
    Go thru this link it might helps you.
    column heading -refer to the webdynpro tutorial 34
    Change the currency data type char and specify the length.
    Thanks,
    Lohi.

  • Formatting the output

    Hi everyone in the forum,
    I do not know if i should post this question here, but i think is the best place. Sorry if i were wrong.
    just a question because i have no idea how to format the output i need.
    I have a REAL or FLOAT and the output restrictions shows that it should be:
    1.0000 D-08 if the value is less than 1
    1.0000 if the value is [1,9]
    1.0000 D+03 is value bigger than 9
    and the other problem is whith other variable (type String) which represents integers, e.g, 0.000000 1.0000000 2.000000; and i have to return only 0 1 2 .
    Any suggestion about how to format the output?
    Thanks

    DecimalFormat

  • Formatting displayed output

    Hi: how do I format the output so that it shows me the complete value for the EVENT_ID field
    ===========
    SQL> select /*+ FIRST_ROWS */ EVENT_ID from EVENT_DATA where AGENT_ID IN (160,212,264);
    EVENT_ID
    4.9561E+18
    4.9561E+18
    ================
    TIA
    Ravi

    You can also change numwidth in sql*plus
    SQL> select 12345678901234567890 from dual;
    12345678901234567890
              1.2346E+19
    SQL> set numwidth 20
    SQL> /
    12345678901234567890
    12345678901234567890

  • Formatting array output

    how do i format the output of an array so that only a certain number of the elements print per line. i know this is basic, i am a beginner and need help.

    final int itemsPerLine = 5;
    int counter = 0;
    String myArray[]; // This will contain your array
    while (counter < myArray.length) {
        System.out.print(myArray[counter]; // Print out the item
        counter++; // increment our counter;
        if (counter%itemsPerLine == 0) {
            System.out.print("\n"); // ad a line return
    }This is one example. It prints out the next string in the array (which you need to initialise and populate first), increments the counter, then checks the modulus to see if its time for a newline.
    Rob.

  • Formatting Binary Output

    I want to format binary output in text fields to confrom to the following scheme:
    head data1 data2 return offSet id
    6 bits 5 bits 5 bits 5 bits 5 bits 6 bits
    where the first row are field names and the second is the filed width.
    What that means is that, using the value 1 (base 10) as an example, a 6 bit filed will read 000001 and so a 5 bit field will read 00001.
    My program converts to binary no worries, but how do I enforce the width requirements? I am using Integer.toBinaryString(int) to convert, if that helps.
    Thanks

    public String intToJustifiedBinaryString(int number, int length)
      StringBuffer buffer = new StringBuffer(Integer.toBinaryString(number));
      while (buffer.length() < length)
          buffer.insert(0, "0");
      return buffer.toString();It works great! Now for the learning. I looked up StringBuffer and found this explanation:
    StringBuffer(String str)
    Constructs a string buffer so that it represents the same sequence of characters as the string argument; in other words, the initial contents of the string buffer is a copy of the argument string.
    What I am trying to figure out is how it is not overwriting what already exists in the buffer. Lets pretend with int = 7 and a 6 bit field.
    So initially, buffer.length() = 3 and my buffer looks like 1 1 1.
    From the API: The principal operations on a StringBuffer are the append and insert methods, which are overloaded so as to accept data of any type. Each effectively converts a given datum to a string and then appends or inserts the characters of that string to the string buffer. The append method always adds these characters at the end of the buffer; the insert method adds the characters at a specified point.
    If I am specifying my insert point as 0 (insert(int offset, char c) Inserts the string representation of the char argument into this string buffer.) How am I not overwriting one of my bits comprising my binary 7? My only guess is that insert operation first shifts what is already there over the necessary amount, based on the length of what is being inserted, before inserting at the specified point. I have read nothing to support this theory. Please let me know if it is correct.
    Thanks for the help!

  • Invalid END header format/no output available for this tool

    help me.
    I install oracle 9i into windows 2k server with pack3. when configuring the ODCA, when OUI prompt:
    invalid END header format&
    no output available for this tool.
    who can tell me that what is happen?
    before this, i had installed this version on windows 2003.

    Dear All
    I have the same problem when installing Oracle9iasR2 on a windows 2000 IBM server
    At the database configuration Assistant of the infrastructutre installation I am always getting this strange message Not a ZIP file (End Header Not found).
    We have tried a lot off scenarios to install Oracle9iasr2 but the installation always fails at the database creation with the followning message
    Not a ZIP file (End Header Not found).
    We had also tried to do the installation using a different copy of CD's with no success.
    Also the same installation on the same server was succesfull with O/S Win2003.
    Then the whole installation fails .
    If anyone has ever faced the same problem and had solved it please advice.
    Thank you in advance.
    Bill

  • Help with formatting multiline output into comma delimited ordered output

    I have 2 tables:
    SQL> desc table_1;
    Name Null? Type
    ===================================
    ID NOT NULL NUMBER
    DATA1 NOT NULL VARCHAR2(440)
    DATA2 NOT NULL VARCHAR2(1024)
    SQL> desc table_2;
    Name Null? Type
    ===================================
    ID NOT NULL NUMBER
    ATTNAME NOT NULL VARCHAR2(255)
    ATTVAL                          VARCHAR2 (4000)
    DATA1 NOT NULL CHAR(1)
    DATA2                          VARCHAR2 (2000)
    DATA3                          VARCHAR2 (255)
    I need to get ATTVAL from where e.g. ATTNAME=att_name1 to ATTNAME=att_name6 from every entry (with its unique ID), and format the output into comma delimited format in e.g. this order:
    att_val1,att_val3,att_val6,att_val4,att_val5,att_val6
    So e.g. for entry with ID "9812" from the query below, the output I need would be:
    187,179,156,134,1436,1809
    What I've got so far is as follows:
    SQL> SELECT id,attname,attval FROM table_2 WHERE id in (SELECT id from table_1 WHERE data2='xxx')
    AND attname in ('att_name1','att_name3','att_name6','att_name4','att_name5','att_name6');
    ID               ATTNAME               ATTVAL
    ===============================
    1970 att_name1 123
    1970 att_name2 abc
    1970 att_name3 1234
    1970 att_name4 def
    1970 att_name5 1134
    1970 att_name6 ghj
    9812 att_name4 134
    9812 att_name5 1436
    9812 att_name3 156
    9812 att_name1 187
    9812 att_name2 179
    9812 att_name6 1809
    77 att_name1 1980
    77 att_name5 1867
    77 att_name3 174
    77 att_name4 1345
    77 att_name2 1345
    77 att_name6 1345
    but I don't know how to format the output comma limited in certain order. (or if this is the best way of getting the data out)
    Would someone have idea how this could be done?

    846954 wrote:
    Thanks Frank!
    I got much further now :).
    I've got Oracle 10g So I used the "SYS_CONNECT_BY_PATH" for my query.
    Now I get the output in the format I want, however, it comes out in the order that the attributes are (which is pretty random).The values you posted are in order: 'attval1' < 'attval2' < ...
    So I'm using this now(had to use "|" as separator because SYS_CONNECT_BY_PATH would not work with comma due to some of the attval having comma in them ):The values you posted don't contain and commas.
    You're hiding what the problem is. It would really help if you posted actual data. It always helps if you post CREATE TABLE and INSERT statements for a little sample data, and the results you want from that data.
    Assuming you really have something that has to be in a certain order, and that order is not based on anything in the values themselves, then DECODE might be a good way to do it. Storing the sort value in a table might be even better.
    It looks like you were using an Oracle 9 exanple. In Oracle 10, using SYS_CONNECT_BY_PATH is simpler:
    SELECT     id
    ,     LTRIM ( SYS_CONNECT_BY_PATH (attval, '|')
               , '|'
               )          AS attvals
    FROM     (
              SELECT     id
              ,     attval
              ,     ROW_NUMBER () OVER ( PARTITION BY  id
                                  ORDER BY          DECODE (...)
                                )     AS curr
              WHERE     id     IN (
                             SELECT  id
                             FROM     table_1
                             WHERE     data2     = 'xxx'
              AND     attname     IN ('attname1','attname2','attname3','attname4','attname5','attname6')
    WHERE     CONNECT_BY_ISLEAF     = 1
    START WITH     curr     = 1
    CONNECT BY     curr     = PRIOR curr + 1
         AND     id     = PRIOR id
    ;You don't need two almost-identical ROW_NUMBERs; one will do just fine.

  • The best format for output

    Hi All,
    working in animation project to be broadcasted on a TV channel as HD1080 50i,
    1- all the animation layers was rendered from TOONBOOM as .SWF to keep it in vector for compositing issue.
    Dose SWF lose any quality? we always use TGA sequence with alpha in our past SD projects but now we found SWF is a smaller file size and allows zooming Because it keeps all vector lines.
    2- compositing each scene in after effects cs6 and then render them.
    What is the best format for output to deal with premiere cs6 as a real time playback ( my editing pc includes gtx680 4gb., many HGST 3tb with raid controller,64g ram, aja kona 3g) so do I go with TGA sequence (I think it will destroy the raid Because of the large number of small-sized files in read and write ) or MOV uncompressed (I'm afraid of the space size and don’t know it will play in real time ) or what is the best compressed format Maintaining video image quality as its now will be my only master source?
    Many thanks,
    sherif

    Thanks Rick for your reply,
    Regarding the SWF i moved to flash pro forums and they are supporting me now,
    My system is a pc, win.64, I7-3930K, 64G RAM, EVGA GTX680 4G, Many HGST 3TB with raid controler,
    Some advised me to go with Quicktime Prores HQ or DNXHD or DPX ,
    In this year project my client's requirement for delivery is :
    DNxHD 120 Codec, wrapped with QuickTime rapper, which means a file with MOV extension and the codec used is DNxHD 120 ( 1080@50i HD)
    So do i work with dnxhd 120 from the beginning to the delivery? (and it will be my only master source) or another format encode it at the end to dnxhd 120? ( i will distribut this project to many channels after the first run exclusivity period end with different requirements).
    Thanks,
    Sherif

  • SqlPlus, output to file ONLY?

    Hey,
    I use SPOOl to write my output to a file but i dont want the result to be printet in the terminal.
    Is there a way to do this?
    Thanks
    //Kenny

    Hi,
    782069 wrote:
    Hello and sorry for my late response,
    I call the script with the following command:
    sqlplus user/pass@database @/path/to/script
    Let's say in the script.sql there's a sql query like this:
    select * from table;
    exit;
    Then the out put would be:
    SQL*Plus: Release 11.1.0.6.0 - Production on Wed Jul 21 09:06:13 2010
    Copyright (c) 1982, 2007, Oracle. All rights reserved.
    Ansluten till: <---- Swedish for "Connected to" :)Men svenska är ett vackert språk! Varför vill du inte se så mycket som möjligt?
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    Column_name1
    Column_name2
    Data1
    Data2
    Swedish for "Disconnected from" Frånkopplad från Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    I can remove the query output with:
    set termout off
    But i want to remove the stuf like:
    Swedish for "Disconnected from" Frånkopplad från Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    Is there a way to remove this? Sorry, not that I know of. I believe Oracle produces that stuff before it even starts to execute your script, so nothing in the script can change it. If there's a way to suppress that output, it's probably some Operating System command.
    Sorry for the messy text but i dont know how i create code boxes :)Type these 6 characters:
    \(all small letters, inside curly brackets) before and after each section of formatted text.  Otherwise, this site compresses whitespace.
    Thanks in advance :DVarsågod!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • SQLPlus Output issue

    Running mutiple versions of SQLPlus with the same issue : 11.1.0.6.0, 11.1.0.7.0, 11.2.0.1.0 connecting to an external suppliers 9.2.0.8 database
    Batch file calls a number of sql scripts and creates and then appends the output to a file like this :
    sqlplus -s user@server @SQLStatement.sql >> %FILENAME%.TMP
    Within the SQL Statment we've got the following set statements then the select :
    set pagesize 0
    set heading off
    set echo off
    set verify off
    set linesize 3999
    set long 1000000
    select lots of XMLELEMENTs Where .......
    Within the output there are single space's, when the end of the line should be a space it actually drops the space and has the next line just after the last character.
    Changing the linesize has no effect other than decressing the number of times it happens by having a less rows by having a larger number.
    Is there a way to get the missing space back within Oracle or will I need to modify the tmp file with something like sed ?
    Many Thanks

    ... But honestly I wasn't facing to any problem with the older version.Neither I, but who knows... Here is a list of add-ons and bugs fixed since version 0.24. The list is extracted from rlwrap's "NEWS" file.
    0.28 rlwrap bug that caused termcap problems on Fedora Core 6
    fixed (thanks Tung Nguyen)
    0.27 when stdin is not a terminal, rlwrap will now exec() the
    specified command instead of complaining
    when stdout or stderr is not a terminal, rlwrap will re-open
    it to /dev/tty (the users terminal) after forking off the
    specified command (so "rlwrap cat > file" will work as a
    quick and dirty line editor)
    rlwrap now remembers inputs of length 1
    -D option to tell rlwrap how agressively it should weed out
    duplicate history entries
    -H option added (history format string)
    Added temporary fix for termcap weirdness on Fedora Core 6
    new -t option for a quick check of terminal capabilities
    (requires configuration with --enable-debug)
    rlwrap -s 0 <command> will now zap <commands> history
    fixed broken reporting of unrecognised options
    0.26 configure on FreeBSD 6.0 still didn't find libutil
    some files were unnecessarily kept open (thanks Stephan Springl)
    on each platform, rlwrap -h now accurately reflects whether
    rlwrap can use long options or optional arguments
    0.25 rlwrap would print input twice when in vi-mode
    rlwrap under FreeBSD 6.0 now uses openpty() from libutil (config
    script fixed)
    -P option added (one-shot rlwrap with pre-given prompt)
    Until now, whem the underlying command was killed by a signal,
    rlwrap would just exit with exit code 0. Now rlwrap will
    cleanup, reset its signal handlers and then send the same signal
    to itself - so that rlwraps parent (usually a shell) doesn't see
    the difference with an un-rlwrapped command
    Regards
    N.J.

Maybe you are looking for

  • Mailto links not opening new Yahoo email

    When I click on mailto links or right click and choose send link Yahoo mail opens, but does not go to a new email. It used to work fine. I recently installed Firefox 6 beta. Should I revert back to an earlier version or is a fix on the way?

  • System Management: Application Monitoring

    I am curious to hear how you all are managing your environment(s) and deployed applications (especially from an operator's viewpoint.) Are you using just EConsole or have you built a "Monitor" app that rides on top of various agents? Thanks in advanc

  • Video list don't work after update to ios 6

    Hi, I have some lists of videos and after upgrade my iphone 4 to IOS 6 they don't work. In iphone that lists come empty. I try made a new one but have same result. The list is empty. On itunes that lists are OK, complete fill in.

  • Implementation scenarios relating to SD

    Hi , Can some one pl let me know the implementation scenarios relating to SD module.. I am new to SD field...Could u please suggest me some important areas i should concentrate .. Thanks in anticipation. Regards Atahar

  • HFR Query on  creating multiple rows - Need urgent help

    I want to create a row template in HFR, there are almost 500 members in rows and we already have them listed in an excel sheet in rows. They are not under a particular hierarchy so cannot choose the relationship functions ( like idesc or children and