Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: sqlplus using Here document does not recognize v$ view ?

Re: sqlplus using Here document does not recognize v$ view ?

From: Galen Boyer <galenboyer_at_hotpop.com>
Date: 17 May 2004 18:23:23 -0500
Message-ID: <ufz9yprod.fsf@standardandpoors.com>


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 Boyer
Received on Mon May 17 2004 - 18:23:23 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US