Misaligned SQLPlus output
Hi,
Yes, I know this should go in the SQLPlus (tumbleweed) forum, but somebody there asked exactly the same question over a month ago and it still hasn't received even one attempted reply!
So, simple question; why is the following output misaligned? Specifically, the value 14 for SAMPLE_SIZE is placed in the middle of its column, and consequently LAST_ANALYZED (21-feb-13) is shoved into the SAMPLE_SIZE column:
1 select column_name, data_type, avg_col_len, density, num_distinct NDV, histogram, num_buckets buckets, sample_
size, last_analyzed,data_type
2 from dba_tab_cols
3 where owner = 'SCOTT'
4 and table_name = 'EMP'
5 and column_name = 'EMPNO'
6* order by internal_column_id
SYS@ORCL> /
COLUMN_NAME DATA_TYPE AVG_COL_LEN DENSITY NDV HISTOGRAM BUCKETS SAMPLE_SIZE LAST_
ANAL DATA_TYPE
EMPNO NUMBER 4 .071428571 14 NONE 1 14 21-FEB-1
3 NUMBER
SYS@ORCL>Btw, the **** above should read A N A L (without the spaces) as in LAST_ANALYZED but a rather enthusiastic filter seems to be at work.
Second question - I was wondering if I had entered a COLUMN ... FORMAT command that had screwed things up..but as far as I can tell, there is no way to retrieve the list of column formats that SQLPlus is currently using - or is there?
*****Edit - ignore the second question - I just found that you can simply type
COLUMNto get a listing of all column formatting instructions currently in use. I checked to see if SAMPLE_SIZE has any formatting applied to it and it does not.
Many thanks,
Jason
Edited by: Jason_942375 on Mar 25, 2013 9:53 PM
Edited by: Jason_942375 on Mar 25, 2013 9:55 PM
Jason_942375 wrote:
Hi guys
Sorry, forgot to "watch" the thread.
Well, thanks for your advice, which all seems to boil down to setting linesize. I should have said, I had already looked at this and discounted it as responsible for the issue. I've been able to refine the problem with the following use case:
SCOTT@ORCL> SHOW LINESIZE
linesize 120
SCOTT@ORCL> DROP TABLE T;
Table dropped.
SCOTT@ORCL> create table T (X number);
Table created.
SCOTT@ORCL> insert into t values (14);
1 row created.
SCOTT@ORCL> commit;
Commit complete.
SCOTT@ORCL> select * from t;
X
14
SCOTT@ORCL> select lpad('Z',100,'Z') dummy , X from T;
DUMMY X
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 14
SCOTT@ORCL>What you can see is that the formatting of the column X changes. When just that column is selected, all is fine. When it is output next to other column output, it gets misaligned.
I think it may have something to do with the Window width, which I currently have set to 115.
If I set the linesize to a few less (not one less) than 115, it seems to wrap the next column okay. But more testing is needed (though it's not exactly the kind of thing you want to waste hours on...although it's bloody annoying!!).Probably a combination of your window width, AND the font. If it is a 'proportional' font, a space will not be as wide as a "Z" or a "W" ... a string of spaces will tend to pull everything following it to the left. Oracle and SQLPlus have no control over how your windows client renders things.
Similar Messages
-
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; -
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 -
HI all,
please see the following script where the variable length is more than a 100 charecters...
When i run this in sqlplus with SERVEROUTPUT ON, i see the ouput being truncated to 100 charecters.
sql> ed
Wrote file afiedt.buf
1 declare
2 l_var varchar2(400);
3 begin
4 l_var := 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh
5 dbms_output.put_line(length(l_var));
6 dbms_output.put_line(l_var);
7* end;
8 /
130
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvI think I am looking for a sqlplus "SET XXXX..." command, but my search has been futile so far.
Please advice.
Thanks,
John.Thanks for your reply .. Frank.
Sorry... I Previewed the post but did not notice my code being truncated in my sqlplus sesssion.
The actual script has the output to 130 charecters. but when i close the edit (afeidt.buf) and execute it, the display only shows 100 charecters...
My SQLPLUS version is 9.2.0.1.
I am using the "WE8ISO8859P1" charecter set.
declare
l_var varchar2(500) := 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz';
begin
dbms_output.put_line(length(l_var));
dbms_output.put_line(l_var);
end;
130
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv
1 declare
2 l_var varchar2(500) ;
3 begin
4 for i in 1 .. 5 loop
5 l_var := l_var || 'abcdefghijklmnopqrstuvwxyz';
6 end loop;
7 dbms_output.put_line(length(l_var));
8 dbms_output.put_line(l_var);
9* end;
sql> /
130
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv -
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
//KennyHi,
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 within bash script
Hey everyone, I wasn't sure if this should go here or in the SQL forum or the Linux forum, but here goes:
Using Oracle10g on Linux, I'm using a bash script to run an sql script, but when I try to echo the results, it shows the output in a single line.
Here's the script
USERLIST=`sqlplus -s / AS SYSDBA <<EOF
set head off
set verify off
set feedback off
SELECT username from dba_users;
exit;
EOF
`
echo $USERLIST;And here's the output:
oracle@apps scripts]$ ./userl.sh
PAYROLL HR2 CORE DEMO TIMEKEEPING SYS EXPENSE Is there anyway so that the output can be shown with line breaks, where all the output is not on one line? I understand I can spool to a file using the spool command, however I'd like to try and get it working this way first.
Any help would be much appreciated, thanks.
Edited by: oscrub on Sep 22, 2010 6:46 PMHandle: oscrub
Status Level: Newbie
Registered: Oct 5, 2008
Total Posts: 7
Total Questions: 4 (3 unresolved)
so many questions & so few answers.
sh t.sh
SYSTEM
SYS
MGMT_VIEW
DBSNMP
SYSMAN
USER1
DBADMIN
HR
OE
SH
BONGO
SCOTT
OUTLN
OLAPSYS
SI_INFORMTN_SCHEMA
OWBSYS
ORDPLUGINS
XDB
ANONYMOUS
CTXSYS
ORDDATA
OWBSYS_AUDIT
APEX_030200
APPQOSSYS
WMSYS
EXFSYS
ORDSYS
MDSYS
FLOWS_FILES
SPATIAL_WFS_ADMIN_USR
SPATIAL_CSW_ADMIN_USR
APEX_PUBLIC_USER
DIP
IX
MDDATA
PM
BI
XS$NULL
ORACLE_OCMHow do you spell S-Q-L? -
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. -
I have a user here experiencing some bizarre behavior w/ sqlplus.
If she logs into database ABDC as user X and executes any script that utilizes dbms_output, she gets the following printed out repeatedly:
SQL> set serveroutput on
SQL> spool gradeload
SQL> exec dummy_package.dummy;
before v-user
before v-user
before v-user
before v-user
before v-user
before v-user
etc....
If I log into the same database, as the same user, from my own computer, or toad, or a terminal window, then I do NOT experience the same behavior.
Seems to me like some sort of variable stored to her sqlplus exe, but I don't really know how that works. Anybody know what's causing this and/or how I can get rid of it?Dear Abdujaparov!
SQL*Plus writes it's output through stdout. Even ORA-XXXX errormessages are written through stdout. The stderr channel is only used if SQL*Plus is suffering an error and terminates abnormaly so you won't get ORA-XXX errormessages into your error file with 2>>.
I think that's not the answer you wanted to hear but I hope that it could be of any help to you.
Yours sincerely
Florian W. -
Sqlplus outputs everything in 1 line
Hello,
A colleague just logged in in his Unix system with sqlplus for the first time in 9i.
The output of a statent is displayed in 1 coninued row and not in collumns.
What can be wrong.
Any ideas ?
Thank youOracle is 9i
EVERY statement will output results in one line
SQL> show linesize;
linesize 80
SQL> show pagesize;
pagesize 14
SQL> show newpage;
newpage 1
SQL>
/app/oracle/product/9.2.0.8/sqlplus/admin:cat glogin.sql
-- Copyright (c) Oracle Corporation 1988, 2000. All Rights Reserved.
-- NAME
-- glogin.sql
-- DESCRIPTION
-- SQL*Plus global login startup file.
-- Add any sqlplus commands here that are to be executed when a user
-- starts SQL*Plus on your system
-- USAGE
-- This script is automatically run when SQL*Plus starts
-- For backward compatibility
SET PAGESIZE 14
SET SQLPLUSCOMPATIBILITY 8.1.7
-- Used by Trusted Oracle
COLUMN ROWLABEL FORMAT A15
-- Used for the SHOW ERRORS command
COLUMN LINE/COL FORMAT A8
COLUMN ERROR FORMAT A65 WORD_WRAPPED
-- Used for the SHOW SGA command
COLUMN name_col_plus_show_sga FORMAT a24
-- Defaults for SHOW PARAMETERS
COLUMN name_col_plus_show_param FORMAT a36 HEADING NAME
COLUMN value_col_plus_show_param FORMAT a30 HEADING VALUE
-- Defaults for SET AUTOTRACE EXPLAIN report
COLUMN id_plus_exp FORMAT 990 HEADING i
COLUMN parent_id_plus_exp FORMAT 990 HEADING p
COLUMN plan_plus_exp FORMAT a60
COLUMN object_node_plus_exp FORMAT a8
COLUMN other_tag_plus_exp FORMAT a29
COLUMN other_plus_exp FORMAT a44 -
Retrieve sqlplus output in a windows variable
How can I put a script output variable in a Windows batch file variable? I am looking for the Windows equivalent of something like this in Unix:
MY_VAR=`sqlplus -s un/pw @myscript`
where myscript.sql is
variable myvar varchar2(20);
begin
<<some code>>
end;
print myvar
exitYou could spool the output to some other file, then use this file somehow.
Also what I do occasionally is using some unix commands under windows. E.g. Search the web for "cygwin". -
How to create sqlplus output spool to a flat file with a header record
Hi all,
I've requirement to spool data from a table to a flat file along with column headings in the first row.I'm getting data but I need header record in the first row also?
Thanks,
Mahender.Hi, Mahender,
If you give this SQL*Plus command before you start SPOOLing
SET PAGESIZE 50000then you can get the usual SQL*Plus column headings, and they won't repeat unless you have more than 50,000 rows of output.
When I can't do that, I use PROMPT
{spool}
SPOOL foo.txt
PROMPT empno ename job mgr ...
SELECT empno, ename, job, mgr ...
PROMPT will trim leading whitespace (unless you enclose it in quotes), but it will leave spacing between the columns alone.
You could also do a separate query, where you select some literals from dual:SPOOL foo.txt
SELECT ' empno ename job mgr ...'
FROM dual;
SELECT empno, ename, job, mgr ... -
Manipulate sqlplus output from a UNION ALL
I have table tA with col a, table tB with col b. Could someone show me how to output the query result like:
a1
b1
a2
b2
a100
b100
not
a1
a2
a100
b1
b2
b100
Thanks.
- ZacSQL> select * from tA;
A
1
2
3
4
5
6
7
8
9
10
10 rows selected.
SQL> select * from tB;
B
1
2
3
4
5
6
7
8
9
10
10 rows selected.
SQL> select 'a', a from tA
2 union all
3 select 'b', b from tB
4 order by 2,1;
' A
a 1
b 1
a 2
b 2
a 3
b 3
a 4
b 4
a 5
b 5
a 6
b 6
a 7
b 7
a 8
b 8
a 9
b 9
a 10
b 10
20 rows selected. -
Supress Warning on SQLPLUS output
Hello!
So, how can i supress warnings on sql plus output?
Let me explain
I have a install script with procedures and somethings have error dependences, this is ok, but i would like remove the "Warning: Procedure created with compilation errors" when execute.
Now, my header is
set verify off
set head off
set echo off
set feedback off
ALTER SESSION SET PLSQL_WARNINGS='DISABLE:ALL';
Thanks for help
Best regards
Felipe.sb92075 wrote:
when all else fail Read The Fine Manual
http://download.oracle.com/docs/cd/E11882_01/server.112/e16604/ch_twelve052.htm#i2700066
WHENEVER SQLERROR WARNING CONTINUESb, thanks for your reply
But the WARNING clause works only with EXIT.
I've tried WHENEVER, ALTER SESSION and DBMS_WARNING but without sucess.
Regards,
Felipe. -
Special characters in sqlplus output
I have a select statement that spools to a file. In the spool file in one of the columns I get returned a series of little boxes. Like below:
oooooooooooooo ( they look like boxes ).
This is from a varchar2 field.
How do I identify the special char and how do I remove it?
thanks.
David.You have a characterset conflict between the client and the server, use the recommendations in NLS_LANG Faq:
http://www.oracle.com/technetwork/database/globalization/nls-lang-099431.html?ssSourceSiteId=otncn
http://www.oracle.com/technetwork/database/globalization/nls-lang-099431.html#_Toc110410563
Edited by: oradba on 05.04.2011 15:25 -
Problem with textboxes in Flash CS5
Hi, I am currently a Flash CS4 user and am trying Flash CS5 currently to see if it is worth it to pay for the upgrade. I currently have a problem with the use of textboxes in CS5 comparing with the previous version. When I try to change the texts of a text box using the following command in actionscript:
showlmytext.text = "My string: " +String(somevariable);
I would get weird misaligned text outputted in my textbox, which exact same code did not cause this problem on Flash CS4.
Can somebody please tell me what is the problem and how can I fix it?
ThanksHi Mario,
I hope you are well. My name is Sandi Langlotz.
At my job at greenidea.com, here in SF; I am having difficulty with using Hebrew in the trial download of CS5 Flash. Russ Mumford my boss has also contacted you regarding our problem.
Flash has a new TLF (Text Layout Format tool). My difficulty has to do with text boxes that are formatted for Right to Left text, with Hebrew selected as the Locale. We are pasting from Microsoft Word.
I hope that you may have a suggestion, a referral or a possible work around for me to try.
I have tried Adobe Customer Service several times to no avail.
Problem 1.
The first sentence below, (in blue) is correct format for Hebrew. Hebrew reads from R to Left.
When I paste the Hebrew text into the Flash animation, one of two things can happen;
the punctuation is cut off of the left side completely; or it is pasted in to the Right side of the Text box, (at the wrong end of the sentence).
I have tried to click the cursor into the left in order to insert the punctuation mark; this works sometimes but often I am unable to click in to manually correct the problem. I don't understand why it is cutting it off, or why I am sometimes unable to click into the left side and insert the punctuation.
Problem 2
In the second paste (the 2nd bold sentence), .CSO on the left side of the sentence is correct, as is the rest of the sentence.
When I paste the text into Flash from Word, Flash puts it in as reversed order. the word CSO. has the punctuation switched to the right (CSO.) Flash reverses the order of the other characters in the sentence also (like in the 2nd black sentence).
שולחן נקי הוא שולחן מאובטח.
שולחן נקי הוא שולחן מאובטח
מבוסס על רעיון ממגזיןCSO .
.CSOןיזגממ ןויער לע ססובמ
Adobe says it supports Right to Left text, but I can find no info on these two buggy problems. Do you have any idea what is wrong?
Thank you ahead of time for any info or referrals you may suggest.
Sandi Langlotz
שולחן נקי הוא שולחן מאובטח.
שולחן נקי הוא שולחן מאובטח
מבוסס על רעיון ממגזיןCSO .
.CSOןיזגממ ןויער לע ססובמ
Maybe you are looking for
-
Hi All, Any one know how the system set net value in sales order item? (VBAP-NETWR) I mean, what kind of condition type will be considered in net value calculation. Thank you
-
How to give valut at runtime in adobe
Hi Suppose made four fields in adobe and connected it to any function module ( by data connection). Now i how to validate these fields using java script and give values at runtime. One more problem is that if i give different names to fields in funct
-
ALV in WD ABAP: add a text field in aggregation line
Hi, I implemented the SALV_WD_TABLE in a web dynpro and I add a column sum; in the new aggregation line I would to edit a field inserting a text: is it possible? I think not because the class cl_salv_wd_aggr_rule has not useful methods, any ideas? th
-
Is there a limitation on the Size of Attachments to SBO Documents?
Hi, Experts. Is there a size limitation to the Attachments that you can Attatch to an SBO Document like an Activity? Does this depend only on the Hardware Specifications, or does SBO also limit the Size of Attachments? Any help would be appreciated.
-
Hello, I downloaded the Premiere Pro CS 5.5 Win SDK, i open the project SDK_Exporter in Visual Studio 2008, when i hit debug i get the following error Error 1 fatal error LNK1104: cannot open file 'C:\Program Files\Adobe\Common\Plug-ins\CS6\MediaCore