Re: Oracle Shell Script
From: The Magnet <art_at_unsu.com>
Date: Tue, 20 Jul 2010 07:10:46 -0700 (PDT)
Message-ID: <b6af7f03-a008-4cda-a0c3-99e1cabc1e9a_at_g6g2000pro.googlegroups.com>
On Jul 20, 4:46 am, gazzag <gar..._at_jamms.org> wrote:
> 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
ERROR at line 1:
ORA-00911: invalid character Received on Tue Jul 20 2010 - 09:10:46 CDT
Date: Tue, 20 Jul 2010 07:10:46 -0700 (PDT)
Message-ID: <b6af7f03-a008-4cda-a0c3-99e1cabc1e9a_at_g6g2000pro.googlegroups.com>
On Jul 20, 4:46 am, gazzag <gar..._at_jamms.org> wrote:
> 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
Put some things together, removing the quotes and changing the name with no luck:
cnt=`sqlplus -s $user/${password} << "EOF"
set heading off feedback off verify off timing off
SELECT count(*) FROM $name;
exit;
EOF`
+ cnt= SELECT count(*) FROM $name
*
ERROR at line 1:
ORA-00911: invalid character Received on Tue Jul 20 2010 - 09:10:46 CDT