Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Formatting SQL Query String

Re: Formatting SQL Query String

From: mpal <mpalkoci_at_yahoo.com>
Date: Mon, 27 Aug 2007 00:52:32 -0700
Message-ID: <1188201152.195175.159730@z24g2000prh.googlegroups.com>


On Aug 27, 12:21 am, vitalis..._at_gmail.com wrote:
> On 27 août, 08:30, mpal <mpalk..._at_yahoo.com> wrote:
>
> > Hi Everyone,
>
> > I was wondering if someone could recommend a good utility / macro /
> > script that would read an SQL statement on input and produce the
> > same statement on output that would be formatted to be easy-to-read.
> > I.E. Inserting new lines, indentation, ... where appropriate.
>
> What is "where appropriate"? No tool can guess the meaning of your
> data.
> Please give at least an example. sqlplus might still be the best tool
> if properly configured.

O.K., I should perhaps be more clear with my question. The question is not about the data, it is about formatting the query.

I am using a reporting tool that automatically generates SQL statement and sends it to Oracle.
For troubleshooting purposes, I need to understand the SQL that is generated by the reporting tool.
The problem is that the generated SQL is not user-friendly formatted.

For example (illustrative example):

Generated SQL:


SELECT DISTINCT tab1.aaa, tab1.bbb, tab1.ccc FROM ( ( ( tabxxx INNER JOIN ( SELECT xxx.aaa, xxx.bbb FROM ...) b on xxx.aaa=b.aaa ... ) )... ) ...

What I would like to see:


SELECT DISTINCT

             tab1.aaa,
             tab1.bbb,
             tab1.ccc
FROM (
              (
                     (
                            tabxxx
                            INNER JOIN
                            ( SELECT
                                   xxx.aaa,
                                   xxx.bbb
                                   FROM
                                   ...
                            ) b
                            on xxx.aaa=b.aaa
                      ...
                     )
             )...

   )
... Received on Mon Aug 27 2007 - 02:52:32 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US