Re: Oracle Shell Script

From: gazzag <gareth_at_jamms.org>
Date: Tue, 20 Jul 2010 02:46:37 -0700 (PDT)
Message-ID: <48efdce0-8cc5-4b26-a4d4-f928890c35c7_at_f6g2000yqa.googlegroups.com>



On 20 July, 05:49, The Magnet <a..._at_unsu.com> wrote:
> I know how to use a shell variable in a query from shell.  Can anyone
> help?
>
> This works fine
> ----------------------
> data_rec=`sqlplus -s $user/${password} << "EOF"
>   set heading off feedback off verify off timing off
>   SELECT owner||':'||name
>   FROM replicated_tables
>   WHERE obj_type = '$type';
>   exit
> EOF`
>
> However, I cannot seem to replace the FROM table:
>
> This Fails
> --------------
> cnt=`sqlplus -s $user/${password} << "EOF"
>   set heading off feedback off verify off timing off
>   SELECT count(*) FROM '$table';
>   exit;
> #EOF`
>
> + cnt=    SELECT count(*) FROM '$table'
>                          *
> ERROR at line 1:
> ORA-00903: invalid table name

Try:

cnt=`sqlplus -s $user/${password} << "EOF"

   set heading off feedback off verify off timing off    SELECT count(*) FROM $table;
   exit;
#EOF` Note: No quote (') around $table.

HTH
-g Received on Tue Jul 20 2010 - 04:46:37 CDT

Original text of this message