DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Unix Env Variable in Sqlpus

  1. #1
    Join Date
    Sep 2002
    Posts
    17

    Exclamation Unix Env Variable in Sqlpus

    I was trying to store the value of a sqlplus select into a Unix environment variable. It worked fine in one Unix server, but the same script failed with syntax error for VALUE in the other server. Both servers are the same version solaris and running same Oracle 8i version. Has anyone used the trick below for Unix env variables and had any similar trouble? Also, are there other ways of accomplishing the same thing?

    Thanks.

    Here is the script
    #!/bin/sh
    VALUE=`sqlplus -s user/password < set pagesize 0 feedback off verify off heading off echo off
    select max(c1) from t1;
    exit;
    END`
    if [ -z "$VALUE" ]; then
    echo "No rows returned from database"
    exit 0
    else
    echo $VALUE
    fi

  2. #2
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712
    I cannot say anything about the syntax you use and why one server works and another doesn't.
    This works OK in SunOS 5.8:
    Code:
    #!/bin/sh
    VALUE=`sqlplus -s user/password <<END
    set pagesize 0 feedback off verify off heading off echo off
    select max(c1) from t1;
    exit;
    END`
    if [ -z "$VALUE" ]; then
    echo "No rows returned from database"
    exit 0
    else
    echo $VALUE
    fi
    Ales
    The whole difference between a little boy and an adult man is the price of toys

Posting Permissions

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


Click Here to Expand Forum to Full Width