Re: Unix to Oracle / Back

From: joel garry <>
Date: Thu, 16 Jul 2009 15:35:37 -0700 (PDT)
Message-ID: <>

On Jul 16, 2:03 pm, The Magnet <> 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:


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;
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.


-- is bogus.
Received on Thu Jul 16 2009 - 17:35:37 CDT

Original text of this message