The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to parse the result of "set" command teodora Shell Programming and Scripting 7 07-02-2008 12:38 PM
Why generate "ash and bash" different output for same bash script? s. murat Shell Programming and Scripting 0 05-26-2008 08:19 AM
Parse "masters" ip from named.conf Citricut Shell Programming and Scripting 2 04-15-2008 05:05 AM
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-20-2007 01:52 AM
Please help formatting bash "time" variable to HH:MM:SS format vikingshelmut Shell Programming and Scripting 3 09-15-2005 09:54 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-05-2009
stagebi stagebi is offline
Registered User
  
 

Join Date: May 2009
Posts: 1
Question "parse" SQL in bash or ksh

Hi!

I've a text file programme1.out :


Code:
CONNECT TO ORACLE (&CONXORA);

CREATE TABLE TABLE1 AS
    SELECT  ID_PERS

        FROM CONNECTION TO ORACLE
        (
        SELECT  DISTINCT PERS.ID_PERS

        FROM TAB_GRP GRP , TAB_PERS PERS

        WHERE DATE_DEB_GRP <= &DATE_QUOTE
              AND (DATE_FIN_GRP IS NULL OR DATE_FIN_GRP > &DATE_QUOTE)
              AND PERS.ID_PERS = GRP.ID_PERS
              AND (PERS.DATE_SUPP_SI IS NULL OR PERS.DATE_SUPP_SI > &DATE_QUOTE)
ORDER BY ID_PERS
);
DISCONNECT FROM ORACLE;
CONNECT TO ORACLE (&CONXORA);

CREATE TABLE TABLE2 AS
  SELECT    ID_PERS,
            ID_PRODUIT,
            CODE_PRODUIT,
            TOP_1
            TOP_2
                
    FROM CONNECTION TO ORACLE
    (
        SELECT ID_PERS,
               ID_PRODUIT,
                CODE_PRODUIT,
                MAX (CASE WHEN (CODE ='01' ) THEN 1 ELSE 0 END) AS TOP_1
                MAX (CASE WHEN (CODE='02' ) THEN 1 ELSE 0 END) AS TOP_2
        FROM TABLE_FROM1
        WHERE  CODE IN ('01','02')
        AND    ID_MOIS <= &ID_MOIS
        GROUP BY ID_PERS,ID_PRODUIT
    );
DISCONNECT FROM ORACLE;

For each query (between connect to oracle and disconnect from oracle), I have to display the name of the create table, the name of tables used (real name of the table) and the name of the columns in the SELECT.

At the end, I would like an output like this : table_create ; table_from ; column_name

Example :

table1;tab_grp;
table1;tab_pers;ID_PERS
table2;table_from1;ID_PRODUIT
table2;table_from1;CODE_PRODUIT
table2;table_from1;TOP_1
table2;table_from1;TOP_2

Is it possible to do this easily with a script in ksh or bash (UNIX AIX IBM)? (with sed, awk..)
Regards
 

Bookmarks

Tags
ksh bash sed awk

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:27 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0