Output parameter

Posted on 2005-05-16
Last Modified: 2010-04-21
Hi everybody,
           i had a shell script which connects to the oracle Db and gets the maximum date from the table i want to store this in a variable and to pass to the calling program. can anybody help me

select max(creation_date) from table name

i want to store that value in a vairable.

Question by:parsi_cnu
    LVL 10

    Accepted Solution

    Not completly ure how you mean it....

    a=`sqlplus user@database/password <<EOF
    select max(creation_date) from table name;

    Like this you have the entire session output in $a and you can filter out the info you need

    or (if you already have that script that gives you just the output you want) then



    Assisted Solution


    Try this :

    var=`sqlplus -s <username>/<passwd> <<SQL_EOF
            set heading off
            set feedback off
            select to_char(max(creation_date),'dd-mon-rr') from table_name;

    echo $var

    You can also write the above code in a seprate script file like, and then in calling program (I assume its a shell script as well) write:


    Cheers :)
    LVL 20

    Expert Comment

    myrizvi, note that your example is flawed in that the here document is unterminated. Never "prettyfy" by indenting a here doc.
    Good thought on shutting sqlplus up a bit though.

    -- Glenn

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
    Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now