1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

How to use Shell scripts in Oracle Database Environment?

Discussion in 'General' started by arunkumar546, Oct 23, 2013.

  1. arunkumar546

    arunkumar546 Active Member

    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    55
    Hi All,

    Now a days most of recrutires are asking about shell script.i know shell script .my question is ,How this shell scripts are used by oracle pl sql developers in real time with sql scripts? anyone expalin with sample example?

    Thanks........
     
  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,347
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    What, exactly, are you asking? If you 'know shell script' then you should be familiar with the 'here document':

    #!/bin/ksh

    if [ $# -eq 0 ]
    then
    echo "Usage: `basename $0` SID"
    exit 9
    fi

    export ORACLE_SID=$1

    sqlplus /nolog <<EOF
    connect / as sysdba

    select sid. serial#, username, program, sql_id, prev_sql_id from v\$session where username is not null;

    EOF


    Such a script will connect to the database, return data for non-null user names and exit. More complex scripts can be written as well.
     
  3. arunkumar546

    arunkumar546 Active Member

    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    55
    Hi zargon,

    Thanks for the reply.Right now i'm working with java developers and i'm working as pl sql developer in windows environment.my question is in unix environment,the pl sql developer work will same as in windows environment? why the shellscripts ,how we are used in real time.according u r example,that script will return non-null user names. Suppose,another script will return some columns in table with data.the same data how will i supply to java developers? or is java devlopers directly include all shell scripts in the application? why i'm asking this, i don't know unix work environment.kindly,please clear my doubt.
     
  4. DTSIGuy

    DTSIGuy Forum Advisor

    Messages:
    402
    Likes Received:
    58
    Trophy Points:
    410
    Location:
    Texas
    Your question implies that a PL/SQL call (or even a SQL query for that matter) will function differently if used from a Windows world as opposed to Unix. PL/SQL itself doesn't care what you're O/S is anymore than the SQL engine does...it only cares about the database and the connection.

    CJ
     
  5. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,347
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    Unix shell scripts are used primarily for three purposes: to execute the same commands on various database instances, to make repetitive tasks easier for the DBA and to schedule tasks, such as backups, etc. from the job scheduler (cron). The PL/SQL scripts won't work any differently in a UNIX environment than they will in Windows. The beauty of shell scripts is you can do multiple tasks in a single shell script where batch files (unless you are using PowerShell) require several different batch files, called from a driving batch file, to accomplish the same goal.

    I think you're confused and don't know quite what to ask; you need to get some practice in a UNIX/Linux enironment looking at, and writing, shell scripts. When you get a feel for what they can do then you can ask how you can apply that knowledge to repeatable tasks in the UNIX/Linux world.