Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 28 Aug 2003 @ 17:00:50 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: SQL beautifier
 
From:   Dieter Noeth

Doug Cox wrote:

  Whats wrong with the Format Query button? Other than occasionally locking up.. It does an OK job..  



Just try to format anything with a SUBSTRING(...FROM...) or EXTRACT(...FROM...)

Before:

        , sum(
            case
              when ( EXTRACT(YEAR FROM l_shipdate) * 100
                     + EXTRACT(MONTH FROM l_shipdate) )
                     =  (  EXTRACT( YEAR FROM (CURRENT_DATE-1) ) * 100
                         + EXTRACT( MONTH FROM (CURRENT_DATE-1) ))
              then l_extendedprice
              else 0
            end )

After Ctrl-Q:

        , sum(
        CASE
                WHEN    ( EXTRACT(YEAR
FROM    l_shipdate) * 100
                     + EXTRACT(MONTH
FROM    l_shipdate) )
                     =  (  EXTRACT( YEAR
FROM    (CURRENT_DATE-1) ) * 100
                         + EXTRACT( MONTH
FROM    (CURRENT_DATE-1) ))
              THEN l_extendedprice
                ELSE    0
        END     )

Or Subqueries or ...

This is just a dumb tokenizer which inserts a CR/LF plus Tabs after some keywords (at least you can get rid of those when you modify keywords.txt).

I really don't know why they don't use a Parser, because they already have one for Teradata SQL ;-)


Dieter



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023