Results 1 to 2 of 2
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 , ...
- 05-05-2009 #1Just Joined!
- Join Date
- May 2009
- Posts
- 1
"Parse" SQL in bash or ksh
Hi!
I've a text file programme1.out :
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.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;
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
- 05-06-2009 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
welcome to the forum
can you show the output from that Oracle macro?
then perhaps we can help you convert that output into
your desired final formthe sun is new every day (heraclitus)


Reply With Quote