We are using Sun server and teradata database. There is a need to upgrade teradata version, but lot of data load is done via ksh scripts, which has embedded SQL in it. Well, Teradata has some words that are reserved words in this new version.
Is there a way to write a script (using awk or something like that) that will look for all these reserved words used in embeded SQL in ksh scripts. All these scripts are located at following location /nisc/tto/scripts I would like to pass above location as parameter to the script via command line. For example reserved words are CONNECT or day_of_year and I want to see all the .ksh scripts at above location that have these word in it and at what line.
Any suggestion will be highly appreciated. Here is a sample script that was used to find a wild card in a select statement:
It is execute as belowsamplescript.awk /nisc/tto/scripts
#!/bin/nawk -f
BEGIN {
}
/[S,s]elect|Sel|sel\ / {
FromCnt = 0
WildCnt = 0
LineNum = 1
FirstLine = NR
}
/[S,s]elect|Sel|sel\ /,/;/ {
Line[LineNum++] = $0
if ($0 ~ /[F,f]rom/ && $0 !~/[T,t]rim/) FromCnt++
if ($0 ~ /\.\*/) WildCnt++
}
/;/ {
if (WildCnt > 1) {
LastLine = NR
print "------> WARNING <------"
for(i=1;i<LineNum;i++)
print Line
printf ("%d Wildcards in above Select\n", WildCnt)
printf ("From count = %d\n", FromCnt)
printf ("In file %s between lines %d and %d\n\n", FILENAME, FirstLine, LastLine)
WildCnt = 0
}
}
Al
Is there a way to write a script (using awk or something like that) that will look for all these reserved words used in embeded SQL in ksh scripts. All these scripts are located at following location /nisc/tto/scripts I would like to pass above location as parameter to the script via command line. For example reserved words are CONNECT or day_of_year and I want to see all the .ksh scripts at above location that have these word in it and at what line.
Any suggestion will be highly appreciated. Here is a sample script that was used to find a wild card in a select statement:
It is execute as belowsamplescript.awk /nisc/tto/scripts
#!/bin/nawk -f
BEGIN {
}
/[S,s]elect|Sel|sel\ / {
FromCnt = 0
WildCnt = 0
LineNum = 1
FirstLine = NR
}
/[S,s]elect|Sel|sel\ /,/;/ {
Line[LineNum++] = $0
if ($0 ~ /[F,f]rom/ && $0 !~/[T,t]rim/) FromCnt++
if ($0 ~ /\.\*/) WildCnt++
}
/;/ {
if (WildCnt > 1) {
LastLine = NR
print "------> WARNING <------"
for(i=1;i<LineNum;i++)
print Line
printf ("%d Wildcards in above Select\n", WildCnt)
printf ("From count = %d\n", FromCnt)
printf ("In file %s between lines %d and %d\n\n", FILENAME, FirstLine, LastLine)
WildCnt = 0
}
}
Al