I need to do all the modification in previous code.
Here firstly i need to check whether
the table exits or not.If exists then searching for line having "ADD constraint" and
need to print the constraint name.
Now if add constraintnot does not exist then need to check for "ADD ( column name" as
we had previously done.Input for "ADD CONSTRAINT" is given below:-
ALTER TABLE PREMIUM_MSGS_SDB ADD CONSTRAINT PK_PREMIUM_MSGS_SDB PRIMARY KEY (MSG_TYPE,COUNTRY_CODE,LEG_VEH);(CODE/)
One more thing in the coding part we are working with a defined format of "alter table"
that is like below:
ALTER TABLE tbla
ADD ( cola1 VARCHAR2(11),
cola2 VARCHAR2(12) );(CODE/)
I want to add some command in my code so that the script will work on all formats.
Is it possible?
script which i needto modify:
#!/bin/sh
#read.sh
sed -n '/ALTER/,/;/p' new.txt > data.txt
sed '/;/ a\
' data.txt > data.ex
/usr/xpg4/bin/awk '
NR==FNR {
tbl[$1]++;
next;
}
/ALTER TABLE/ {
tbl_name = $3;
if (tbl_name in tbl)
getcols = 1
else getcols = 0;
next;
}
getcols != 1 {
printf "%-12s\t %-12s\t %-12s\t %s\t\t %s\n" , tbl_name , "N/A" , "N/A" , "N/A" , "NIL";
next ;
}
/^ADD/,/;[[:space:]]*$/ {
f = ($1 ~ /^ADD/ ? 3 : 1);
sub(/).*/, "
", $(f+1));
printf "%-12s\t %-12s\t %-12s\t %s\t %s\n" , tbl_name, $f, $(f+1) , "NOT NULL" ,"Y";
}
' table data.ex > result
echo "
1i
"`grep "DDCF No." new.txt`\n"
TABLE_NAME\t\t COLUMN_NAME\t DATA_TYPE\t VALUE\t\t STATUS\n
.
wq
" | ex -s result
uniq result > result1
cat result1(CODE/)
---------- Post updated at 12:15 AM ---------- Previous update was at 12:02 AM ----------
Sorry to all because my post is not in good format but i am helpless i am trying to edit it but its not working and also not wrapingthe codes