0

Please Find the code below. I am not able to understand what is going wrong and where.

date1='20120101'
echo ${date1}
date_with_slash=`nawk -v var=${date1} 'BEGIN {print substr(var,7,2)}'`/`nawk -v var=${date1} 'BEGIN {print substr(var,5,2)}'`/`nawk -v var=${date1} 'BEGIN {print substr(var,1,4)}'`
echo ${date_with_slash}

Value_Range='VALLLLLUUUUEEE'
echo $Value_Range
Value_Range = `sqlplus -s lode/lode@oropl_gw <<EOF
set serveroutput on
declare

    Value_Range varchar2(20):='val';
    ddate varchar2(20):=${date_with_slash};
    begin
    select to_char(sysdate + 2 - (select trunc(sysdate)- to_date('${date_with_slash}','dd/mm/yyyy') from dual),'yyyymmdd') into Value_Range from dual;
    dbms_output.put_line(Value_Range);
    end;
    /
    exit
    EOF`
echo date1 is ${date1}
echo value is ${Value_Range}
William Pursell
  • 204,365
  • 48
  • 270
  • 300
  • What are you trying to do? What did you expect? What happened? And, please, correct the formatting of your code, it is unreadable as it stands now. – Hans Lub Dec 30 '12 at 20:06
  • all of the calls to nawk in the `date_with_slash` can be rolled up into 1 call to nawk. Rad about the printf statement in nawk. Good luck. – shellter Dec 31 '12 at 01:55

1 Answers1

0

You must remove the spaces aroung = in the assignment:

Value_Range=`sqlplus -s lode/lode@oropl_gw <<EOF

See: Bash script variable declaration - command not found

Community
  • 1
  • 1
William Pursell
  • 204,365
  • 48
  • 270
  • 300
  • Indeed, and those spaces would make the shell complain ("command not found: Value_Range") @Urvashi: Is this what happens? If not, what *does* happen? – Hans Lub Dec 30 '12 at 22:52