Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009

    Unanswered: Problem With SQLPLus Written in unix shell script


    I am having a strange issue while writing sql-plus inside a shell script.
    I am accessing the dbms_stats.gather_table_stats() package in Oracle.

    When I am directly giving partition name as parameter,it is collecting stats.

    But I need to execute the shell script everyday so the parameter should be like this
    P20090806(year,month and day-1).Currently I am querying the dual table like this select concat('P',to_char(sysdate-1,'yyyymmdd'));

    iam achieving this by doing like this

    P=`sqlplus username/password@schema <<EOF

    select concat('P',to_char(sysdate-1,'yyyymmdd'));


    when I am trying to substitute the variable 'P' in the parameter list ,I am getting error.

    Can someone help me to do this based on the requirement mentioned

  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    >I am querying the dual table like this select concat('P',to_char(sysdate-1,'yyyymmdd'));
    OK, but line below is lacking & not valid SQL
    >select concat('P',to_char(sysdate-1,'yyyymmdd'));
    Last edited by anacedent; 08-07-09 at 01:12.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Aug 2009
    Olympia, WA
    Ok, you are using MySQL syntax in Oracle (concat).
    SQL should read
    SELECT 'P' || to_char(sysdate-1, 'YYYYMMDD')
    Secondly, your command should be enclosed in backticks, you only started with a backtick.

    And perhaps most importantly, why are you using an oracle call to get a date string?

    `date +%Y%m%d`

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts