- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Formatting v$sqltext.SQL_TEXT
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2004 09:35 PM
тАО04-07-2004 09:35 PM
Does anybody have a method to get a human readable output on the SQL_TEXT field when looking at a running session this way :
SELECT
'EN COURS' REQ,
v$session.sid,
piece,
SQL_TEXT
FROM
v$SESSION,
v$SQLTEXT SQLTEXT
WHERE
v$SESSION.SQL_ADDRESS= SQLTEXT.ADDRESS AND
SQLTEXT.HASH_VALUE = v$SESSION.SQL_HASH_VALUE AND
v$SESSION.SID = &1
ORDER BY
v$session.sid,
v$session.username,
v$session.osuser,
piece
;
Thank for you help,
Nicolas
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2004 10:00 PM
тАО04-07-2004 10:00 PM
Re: Formatting v$sqltext.SQL_TEXT
column sql_text heading "SQLTEXT" word_wrapped justify right format A(30)
Instead of word_wrapped, wrapped (default), truncated can also be used.
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 02:02 AM
тАО04-08-2004 02:02 AM
Re: Formatting v$sqltext.SQL_TEXT
Enjoy,
Hein
usage: perl pretty.pl < tmp.lst
$x{"SELECT"}="\n";
$x{"INSERT"}="\n";
$x{"UPDATE"}="\n";
$x{"WHERE"}=" ";
$x{"FROM"}=" ";
$x{"INTO"}=" ";
$x{"AND"}=" ";
$x{"OR"}=" ";
$x{"GROUP"}=" ";
$x{"ORDER"}=" ";
$x{"newline"}=" ";
while (<>) {
if (length >= 64) {
$data=1;
$_ = substr($_,0,64);
s/\(/ \(/g;
s/\)/\) /g;
s/\s+/ /g;
s/^ //;
$buf .= $_;
} else {
if ($data==0) {
print;
next;
}
@words = split (/\s/,$buf);
foreach $word (@words) {
if (defined( $x{$word} )) {
print "$line\n";
$line = $x{$word}.$word;
} else {
if (length($line) > 57) {
print "$line\n";
$line = $x{"newline"}.$word;
} else {
$line = $line . " " . $word;
}
}
}
print "$line\n";
$line = "";
$buf = "";
}
}
Before:
SELECT SQL_TEXT FROM v$SESSION, v$SQLTEXT SQLTEXT WHERE v$SESSIO
N.SQL_ADDRESS= SQLTEXT.ADDRESS AND SQLTEXT.HASH_VALUE = v$SESSIO
N.SQL_HASH_VALUE AND v$SESSION.SID = 25 ORDER BY v$session.sid,
v$session.username, v$session.osuser, piece
After:
SELECT SQL_TEXT
FROM v$SESSION, v$SQLTEXT SQLTEXT
WHERE v$SESSION.SQL_ADDRESS= SQLTEXT.ADDRESS
AND SQLTEXT.HASH_VALUE = v$SESSION.SQL_HASH_VALUE
AND v$SESSION.SID = 25
ORDER BY v$session.sid, v$session.username, v$session.osuser,
piece
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 02:17 AM
тАО04-08-2004 02:17 AM
Re: Formatting v$sqltext.SQL_TEXT
Hein :
1) The script attached is not the perl one
2) The script does a good job, but the last line of the SQL reques is not processed !
If I may suggest another improvement, the fields after the select might as well be displayed one per line.
Anyway, this is what I'm looking for.
Cheers
Nicolas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 02:32 AM
тАО04-08-2004 02:32 AM
Re: Formatting v$sqltext.SQL_TEXT
Ooops! I am surprised it works at all with the mangling of the spaces in the forum entry.
Let me try that attach again....
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 04:00 AM
тАО04-08-2004 04:00 AM
Re: Formatting v$sqltext.SQL_TEXT
Even with the detached script, it doesn'process the last line.
Use the attached file if you want to see for your self.
Nicolas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 05:27 AM
тАО04-08-2004 05:27 AM
Re: Formatting v$sqltext.SQL_TEXT
The original script tried to handle multiple chunks of ugly-sql interspersed with text/data chunks, but it did not solve that problem good enough for your need (it was good enough for me back then! :-).
Here is a version that does work on the last line, and handles your long comma seperated liste nicer (imho).
I'm sure there is plenty wrong with it still (quoted strings, other key words,...) but it does the job on your examples.
Included and attached (for spacing!).
Hein.
(btw... did you assign 3 points to put me on 1000 exactly in the hpux section? :-).
#
%x = ("SELECT", "\n", "INSERT", "\n", "UPDATE", "\n",\
"WHERE", " ", "FROM", " ", "INTO", " ", "AND", " ",\
"OR", " ", "GROUP", " ", "ORDER", " ", "newline", " ");
while (<>) {
$_ = substr($_,0,64);
s/\,/\, /g; #Multi-space removed later.
s/\(/ \(/g;
s/\)/\) /g;
s/\s+/ /g;
s/ ,/,/g;
s/^ //;
$buf .= $_;
}
@words = split (/\s/,$buf);
foreach $word (@words) {
if (defined( $x{$word} )) {
print "$line\n";
$line = $x{$word}.$word;
} else {
if (length($line) > 57) {
print "$line\n";
$line = $x{"newline"}.$word;
} else {
$line = $line . " " . $word;
}
}
}
print "$line\n";
after:
INSERT
INTO tTEMPBAL0rst (NUMSEQCOG, APPLI_CPB, ACCOUNT, ALTACCT,
BUSINESS_UNIT, LEDGER_GROUP, FK_PERIOD, IND_EXLCVA,
CPT_NAT, JOURNAL_DATE, JRN_DATE, CODDIV, LIBDIV, CODACT,
LIBACT, GOP_MNE, GOP_LIB, PTF_MNE, PTF_LIBCRT, FK_STR,
CPT_PCI_S, CPT_PCI, FOREIGN_CURRENCY, IND_IAS, CDE_POS,
TYPE_RESULTAT, SOLDE_DBT, SOLDE_CRD, SOLDE) (SELECT
/*+ USE_NL(TMEURST) */ 40709, TM.APPLI_CBL, TM.ACCOUNT,
TM.ALTACCT, TM.BUSINESS_UNIT, TM.LEDGER_GROUP, TM.FK_PERIOD,
TM.IND_EXLCVA, TM.CPT_NAT, TM.JOURNAL_DATE, TM.JRN_DATE,
TSTRRST.CODDIV, TSTRRST.LIBDIV, TSTRRST.CODACT, TSTRRST.LIBACT,
TSTRRST.GOP_MNE, TSTRRST.GOP_LIB, TSTRRST.PTF_MNE,
TSTRRST.PTF_LIBCRT, TM.FK_STR, NVL (TM.CPT_PCR, -1),
TM.CPT_PCR, TM.FOREIGN_CURRENCY, TM.IND_IAS, TM.CDE_POS,
kRPTUTILrst.F_GET_TYPE_RESULTAT_RST ('BAL', 'D', TO_DATE
('15/03/2004', 'DD/MM/YYYY'), TO_DATE ('31/03/2004',
'DD/MM/YYYY'), TM.JRN_DATE), decode (TM.SENS_MVT, 'D',
TM.MNT_TRAN, 0) SOLDE_DBT, decode (TM.SENS_MVT, 'C',
TM.MNT_TRAN, 0) SOLDE_CRD, decode (TM.SENS_MVT, 'D',
TM.MNT_TRAN, 0) - decode (TM.SENS_MVT, 'C', TM.MNT_TRAN,
0) SOLDE
FROM TSTRRST, TMEURST TM WHERE TM.FK_STR=TSTRRST.PK_STR
AND TSTRRST.PTF_MNE in ('TRIND')
AND TM.BUSINESS_UNIT='G0001'
AND TM.LEDGER_GROUP='LEDGRP7003'
AND TM.IND_IAS='N'
AND TM.CDE_POS in ('N', 'S')
AND JRN_DATE BETWEEN TO_DATE ('01/03/2004', 'DD/MM/YYYY')
AND TO_DATE ('31/03/2004', 'DD/MM/YYYY')
AND JOURNAL_DATE BETWEEN TO_DATE ('29/02/2004', 'DD/MM/YYYY')
AND TO_DATE ('31/03/2004', 'DD/MM/YYYY') )
before:
INSERT INTO tTEMPBAL0rst (NUMSEQCOG,APPLI_CPB,ACCOUNT,ALTACCT,BU
SINESS_UNIT,LEDGER_GROUP,FK_PERIOD,IND_EXLCVA,CPT_NAT,JOURNAL_DA
TE,JRN_DATE,CODDIV,LIBDIV,CODACT,LIBACT,GOP_MNE,GOP_LIB,PTF_MNE,
PTF_LIBCRT,FK_STR,CPT_PCI_S,CPT_PCI,FOREIGN_CURRENCY,IND_IAS,CDE
_POS,TYPE_RESULTAT,SOLDE_DBT,SOLDE_CRD,SOLDE) (SELECT /*+ USE_NL
(TMEURST) */ 40709, TM.APPLI_CBL, TM.ACCOUNT, TM.ALTACCT, TM.BUS
INESS_UNIT, TM.LEDGER_GROUP, TM.FK_PERIOD, TM.IND_EXLCVA, TM.CPT
_NAT, TM.JOURNAL_DATE, TM.JRN_DATE, TSTRRST.CODDIV, TSTRRST.LIBD
IV, TSTRRST.CODACT, TSTRRST.LIBACT, TSTRRST.GOP_MNE, TSTRRST.GOP
_LIB, TSTRRST.PTF_MNE, TSTRRST.PTF_LIBCRT, TM.FK_STR, NVL(TM.CPT
_PCR,-1), TM.CPT_PCR, TM.FOREIGN_CURRENCY , TM.IND_IAS , TM.CDE_
POS , kRPTUTILrst.F_GET_TYPE_RESULTAT_RST('BAL', 'D', TO_DATE('1
5/03/2004','DD/MM/YYYY'), TO_DATE('31/03/2004','DD/MM/YYYY'), TM
.JRN_DATE), decode(TM.SENS_MVT,'D',TM.MNT_TRAN ,0) SOLDE_DBT, de
code(TM.SENS_MVT,'C',TM.MNT_TRAN ,0) SOLDE_CRD, decode(TM.SENS_M
VT,'D',TM.MNT_TRAN ,0) - decode(TM.SENS_MVT,'C',TM.MNT_TRAN ,0)
SOLDE FROM TSTRRST, TMEURST TM WHERE TM.FK_STR=TSTRRST.PK_STR AN
D TSTRRST.PTF_MNE in ('TRIND') AND TM.BUSINESS_UNIT='G0001' AND
TM.LEDGER_GROUP='LEDGRP7003' AND TM.IND_IAS='N' AND TM.CDE_POS
in ('N','S') AND JRN_DATE BETWEEN TO_DATE('01/03/2004','DD/MM/Y
YYY') AND TO_DATE('31/03/2004','DD/MM/YYYY') AND JOURNAL_DATE B
ETWEEN TO_DATE('29/02/2004','DD/MM/YYYY') AND TO_DATE('31/03/200
4','DD/MM/YYYY') )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 09:31 PM
тАО04-08-2004 09:31 PM
Re: Formatting v$sqltext.SQL_TEXT
Thanks for the timle you took to improve you perl script.
It's a nice output indeed !
Fort the 3 pts, there was no special thinking on it, I felt the correction was at leat worth some points.
The 10 pts you get now are well deserved !
Cheers
Nicolas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 11:15 PM
тАО04-08-2004 11:15 PM
Re: Formatting v$sqltext.SQL_TEXT
perhaps you overlooked a small detail.
A ten is made of a 1 and a 0 and not only of
a 0!
You have given Hein 0 points for the last post!
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 11:16 PM
тАО04-08-2004 11:16 PM
Re: Formatting v$sqltext.SQL_TEXT
perhaps you overlooked a small detail.
A ten is made of a 1 and a 0 and not only of
a 0! ;-)
You have given Hein 0 points for the last post!
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2004 12:00 AM
тАО04-09-2004 12:00 AM
Re: Formatting v$sqltext.SQL_TEXT
Hein, all appologies.
Please say hello to get your 10 pts.
Nicolas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-12-2004 08:21 PM
тАО04-12-2004 08:21 PM
Re: Formatting v$sqltext.SQL_TEXT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-13-2004 09:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-13-2004 09:10 PM
тАО04-13-2004 09:10 PM
Re: Formatting v$sqltext.SQL_TEXT
I like you personal quote.
Can I say the script is not flawles but keep my own shoes ?
Cheers
Nicolas