Results 1 to 8 of 8
Thread: Awful SQL output with v6
-
11-22-2011, 03:24 AM #1
Awful SQL output with v6
Hi,
for my everyday checks I use some scripts from the command line, something like:
With TSM v5 it's easy to have a "nice looking" output, it's sufficient to have a well sized window and you'll have something like:Code:select NODE_NAME,PLATFORM_NAME,DOMAIN_NAME,TCP_NAME,TCP_ADDRESS,(CURRENT_DATE - date(LASTACC_TIME)) as LAST_ACC from NODES where NODE_NAME like upper('%$1%')
Well, with v6 you'll have:Code:tsm: TSMU04>run qip test NODE_NAME PLATFORM_NAME DOMAIN_NAME TCP_NAME TCP_ADDRESS LAST_ACC ------------------ ---------------- ------------------ ------------------ ------------------ -------- TESTSQL TDP MSSQL Win64 PD_SQL TIDBSTIM02WTST 10.248.164.82 665
It looks like v5 will trim unnecessary blanks and v6 will not, I even tried to cast all columns as varchar but it looks like some columns aren't cast as I wanted.Code:NODE_NAME: IPTSVIL PLATFORM_NAME: WinNT DOMAIN_NAME: PD_BA TCP_NAME: IPTSVIL TCP_ADDRESS: 10.233.163.104 LAST_ACC: 0
Is there any better (and faster) way to have the same output on v6 as v5? Keep in mind that I'm talking about scripts that I use on the admin command line and not as external (so no dataonly etc.).
Thanks.
EDIT: While writing I said that looks like v6 doesn't "trim" so I even tried to ltrim(rtrim(COLUMN)) but it didn't work.Last edited by Rigido; 11-22-2011 at 03:34 AM.
-
11-22-2011, 07:30 AM #2
Hi Rigido,
Instead of TRIM, you can use the RPAD scalar function. For example: Select RPAD(node_name,20) as node, RPAD(platform_name,20) as platform from nodes.
Zoli
-
The Following User Says Thank You to zsoltesz For This Useful Post:
Rigido (11-22-2011)
-
11-22-2011, 09:38 AM #3
Thank you Zoli, rpad function is perfect, but I think the problem is somewhere else...
If the output is <=78 it worksIf the output is >78 it doesn't work, no matter how large is your window (mine is 120columns)Code:tsm: TSMU07>select rpad(NODE_NAME,18),rpad(PLATFORM_NAME,15),rpad(DOMAIN_NAME,10),rpad(TCP_NAME,15),rpad(TCP_ADDRESS,15),rpad((CURRENT_DATE - date(LASTACC_TIME)),5) as LAST from NODES where NODE_NAME like upper('%svil%') Unnamed[1] Unnamed[2] Unnamed[3] Unnamed[4] Unnamed[5] LAST ------------------- ---------------- ----------- ------------------------------- ------------------------------- ------ IPTSVIL WinNT PD_BA IPTSVIL 10.233.163.104 0Does someone know if there is a setting somewhere in DB2/TSM?Code:tsm: TSMU07>select rpad(NODE_NAME,19),rpad(PLATFORM_NAME,15),rpad(DOMAIN_NAME,10),rpad(TCP_NAME,15),rpad(TCP_ADDRESS,15),rpad((CURRENT_DATE - date(LASTACC_TIME)),5) as LAST from NODES where NODE_NAME like upper('%svil%') Unnamed[1]: IPTSVIL Unnamed[2]: WinNT Unnamed[3]: PD_BA Unnamed[4]: IPTSVIL Unnamed[5]: 10.233.163.104 LAST: 0
Grazie.
-
11-22-2011, 12:41 PM #4
Please read this article from IBM: http://www-01.ibm.com/support/docvie...CSSGSG7&mync=R
Zoli
-
11-22-2011, 05:22 PM #5
Thank you again Zoli but that article doesn't explain where it will get the "single line" width.
As I wrote before, my window is 120 columns wide and every columns of the select is "rpadded" to keep total length under control, but if you want a table output the total length MUST be under 79 chars.
And you know what?
Take a look at the 78 chars output and count how many chars are EFFECTIVELY there...119! In fact colum 4 and 5 are wider than rpad value of 15.
I think I'm going to open an APAR at IBM.
-
11-23-2011, 03:55 AM #6
Ok, it is not so simple...still investigating.
Does someone know why 15 chars "dpadded" columns as TCP_NAME and TCP_ADDRESS are shown as a 30 chars dpadded column?
Just to be sure:Code:tsm: TSMU07>select max(length(TCP_NAME)) from nodes Unnamed[1] ------------ 15Last edited by Rigido; 11-23-2011 at 04:00 AM.
-
08-24-2012, 04:33 AM #7Member
- Join Date
- Sep 2002
- Location
- DK
- Posts
- 26
- Thanks
- 0
- Thanked 0 Times in 0 Posts
Hi
Sorry to "reopen" this old thread, but I would like to know if you found a solution to this. I'm dealing with the same issues and would like to have the cleaner output in v. 6.
/G
-
08-24-2012, 11:56 AM #8
My only solution was to do as you did, or to dump the file to a delimited file and use PERL to format a better report.
Similar Threads
-
tsm sql query output format
By bxtr97 in forum ScriptingReplies: 5Last Post: 11-29-2010, 06:18 PM -
SQL Select output to file
By scottgassTSM in forum ScriptingReplies: 4Last Post: 05-09-2008, 05:42 AM -
Simple SQL query into single-line output?
By kzw2zx in forum ScriptingReplies: 10Last Post: 02-13-2008, 03:21 PM -
sql select and blank line in output?
By Stephan in forum ScriptingReplies: 0Last Post: 01-17-2007, 01:24 PM -
Export Server Scripts/SQL query output
By vogant in forum ScriptingReplies: 1Last Post: 09-04-2006, 10:39 AM


Reply With Quote
