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

Thread: How can I run an SQL command from Unix command prompt?

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Posts
    37

    How can I run an SQL command from Unix command prompt?

    The trouble is, if I run in following way

    $ORACLE_HOME/bin/sqlplus user/pwd@database @'/data/src/myfile.sql'

    after running the script, the prompt remain within SQL Plus environment. I want it to get back in Unix command prompt.

    Thanx

  2. #2
    Join Date
    Jul 2002
    Location
    Northampton, England
    Posts
    612
    Add an EXIT to the end of your script call?

    Code:
    $ORACLE_HOME/bin/sqlplus user/pwd@database @'/data/src/myfile.sql' exit

  3. #3
    Join Date
    May 2002
    Posts
    2,645
    Or run a shell script.

  4. #4
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166

    Re: How can I run an SQL command from Unix command prompt?

    Originally posted by sbasak1
    The trouble is, if I run in following way

    $ORACLE_HOME/bin/sqlplus user/pwd@database @'/data/src/myfile.sql'

    after running the script, the prompt remain within SQL Plus environment. I want it to get back in Unix command prompt.

    Thanx
    You can put an exit in you sql script as waitecj has suggested.
    Or you can write a shell script as Stecal has suggested.

    As an example
    Code:
    #!/usr/bin/sh
    export ORACLE_HOME=/usr/export/oracle/9.2/bin
    export ORACLE_SID=mysid
    export LD_LIBRARY_DIR=$ORACLE_HOME/lib
    
    sqlplus /nolog << EOF
    connect / as sysdba
    --insert sql here
    EOF
    exit
    Of course I might have missed something as I am only a developer.

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