Well, to start with, since you're
awk expression is enclosed in single quotes, the shell variables in it will not expand. You generally have to import shell variables into
awk variables with the
-v option if you want to use them.
But as I said, you really shouldn't be using
awk in the first place. Have you given any thought at all to the solutions I mentioned before?
Now to cover a few other points about your script:
1) What kind of output do the
sqlplus commands produce? It would help in figuring out the script to know what kind of values it's using.
2) The way you set your array may not be the safest or most efficient method. If the input is newline delimited perhaps you could use
mapfile. Or just a simple
read if delimited in some other fashion.
3) Use a
c-style for loop instead of a
while loop, or just use a regular
for loop and run it directly on the array.
3a) When using advanced shells like
bash or
ksh, it's recommended to use
[[..]] for string/file tests, and
((..)) for numerical tests. Avoid using the old
[..] test unless you specifically need POSIX-style portability.
http://mywiki.wooledge.org/BashFAQ/031
http://mywiki.wooledge.org/ArithmeticExpression
4) Your "value=" setting does not capture the output of your commands. Where's the necessary
command substitution brackets?
5)
Useless Use Of Cat.