Re: Unix to Oracle / Back
From: The Magnet <art_at_unsu.com>
Date: Thu, 16 Jul 2009 18:45:23 -0700 (PDT)
Message-ID: <1f536aa6-bf16-4017-98e2-cfca6f00ebd1_at_a7g2000yqk.googlegroups.com>
On Jul 16, 5:35 pm, joel garry <joel-ga..._at_home.com> wrote:
> On Jul 16, 2:03 pm, The Magnet <a..._at_unsu.com> wrote:
>
>
>
> > I'm trying to accomplish this:
>
> > estimates=`sqlplus -s $user/${password} << " EOF"
> > set heading off feedback off verify off timing off
> > SELECT count(*)
> > FROM daily_estimates
> > WHERE TO_CHAR(date_appended,'YYYYMMDD') = '$yyyymmdd';
> > exit
> > EOF`
>
> > I get nothing. If I hard code an actual date in there, it works
> > fine. Why is Oracle not resolving the variable? I've seen this on
> > many pages and it works fine there.......
>
> > Oracle 10g R2. Using ksh......
>
> > Many thanks!
>
> Oddly, this also works:
>
> yyymmdd=`date`
> user=xxx
> password=yyy
> echo $user
> echo $password
> echo $yyymmdd
> estimates=`sqlplus -s $user/${password} <<EOF
> set heading off feedback off verify off timing off
> SELECT count(*),'blorf','$yyymmdd'
> FROM dual;
> exit
> EOF
> `
> echo $estimates
>
> The issue is that (per Unix Power Tools) white space and newlines both
> become argument separators when in backquotes. That's why you can put
> a command that outputs things on separate lines in backquotes and they
> are treated as though they are parameters on the same line. That's
> not the trick I thought I was about to remember. That's not how I
> always thought putting quotes around a hereis delimiter worked - when
> I first started this second post, I had thought a backslash was
> necessary on the line before the EOF to force the newline not to be
> like whitespace. Learn something new every day.
>
> jg
> --
> _at_home.com is bogus.http://blog.mozilla.com/security/2009/07/14/critical-javascript-vulne...
Date: Thu, 16 Jul 2009 18:45:23 -0700 (PDT)
Message-ID: <1f536aa6-bf16-4017-98e2-cfca6f00ebd1_at_a7g2000yqk.googlegroups.com>
On Jul 16, 5:35 pm, joel garry <joel-ga..._at_home.com> wrote:
> On Jul 16, 2:03 pm, The Magnet <a..._at_unsu.com> wrote:
>
>
>
> > I'm trying to accomplish this:
>
> > estimates=`sqlplus -s $user/${password} << " EOF"
> > set heading off feedback off verify off timing off
> > SELECT count(*)
> > FROM daily_estimates
> > WHERE TO_CHAR(date_appended,'YYYYMMDD') = '$yyyymmdd';
> > exit
> > EOF`
>
> > I get nothing. If I hard code an actual date in there, it works
> > fine. Why is Oracle not resolving the variable? I've seen this on
> > many pages and it works fine there.......
>
> > Oracle 10g R2. Using ksh......
>
> > Many thanks!
>
> Oddly, this also works:
>
> yyymmdd=`date`
> user=xxx
> password=yyy
> echo $user
> echo $password
> echo $yyymmdd
> estimates=`sqlplus -s $user/${password} <<EOF
> set heading off feedback off verify off timing off
> SELECT count(*),'blorf','$yyymmdd'
> FROM dual;
> exit
> EOF
> `
> echo $estimates
>
> The issue is that (per Unix Power Tools) white space and newlines both
> become argument separators when in backquotes. That's why you can put
> a command that outputs things on separate lines in backquotes and they
> are treated as though they are parameters on the same line. That's
> not the trick I thought I was about to remember. That's not how I
> always thought putting quotes around a hereis delimiter worked - when
> I first started this second post, I had thought a backslash was
> necessary on the line before the EOF to force the newline not to be
> like whitespace. Learn something new every day.
>
> jg
> --
> _at_home.com is bogus.http://blog.mozilla.com/security/2009/07/14/critical-javascript-vulne...
Hmmm...I'm playing with this:
estimates=`sqlplus -s $user/${password} <<EOF
set heading off feedback off verify off timing off
SELECT count(*)
FROM daily_estimates
WHERE TO_CHAR(date_appended,'YYYYMMDD') = '$yyyymmdd';
exit
EOF`
I get this: here document `EOF' unclosed
Received on Thu Jul 16 2009 - 20:45:23 CDT