Re: Oracle Shell Script
From: Eric <eric_at_deptj.eu>
Date: Tue, 20 Jul 2010 07:55:08 +0100
Message-ID: <slrni4ai2c.4vi.eric_at_teckel.deptj.eu>
On 2010-07-20, The Magnet <art_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
>
>
Date: Tue, 20 Jul 2010 07:55:08 +0100
Message-ID: <slrni4ai2c.4vi.eric_at_teckel.deptj.eu>
On 2010-07-20, The Magnet <art_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
>
>
Why have you put single quotes around $table ? That prevents the substitution from taking place, hence the error.
E. Received on Tue Jul 20 2010 - 01:55:08 CDT