Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: sqlplus using Here document does not recognize v$ view ?
Not only are people telling you the correct solution, escape the
$. But, if you think about it, thats a pretty powerful scripting
mechanism that shell gives you.
#!/bin/sh
table=$1
sqlplus ... << EOSQL
select count(*) from $table;
EOSQL
You call the script at the command-line with, say "EMP" as a
parameter, the "$table" gets replaced with "EMP". and you get
the count of EMP. Maybe you then upgrade it to accept a
comma-delimited string of column-names?
#!/bin/sh
table=$1
columnnamelist=$2
sqlplus ... << EOSQL
select $columnnamelist, count(*) from $table group by $columnnamelist;
EOSQL
The world is your oyster and pretty useful in my book.
-- Galen BoyerReceived on Mon May 17 2004 - 18:23:23 CDT