Shell script and plsql

Please guide me with parameter passing at 3 levels. Here is the scenario.
a. A plsql-generateMaster.plsql- invokes stored procedure genMDetails(param1, query)
b. A shell script genM.sh invokes generateMaster.plsql
c. Need to pass date range as parameters (2 dates) to shell script.
d. The shell scripts accepts the date range parameters and passes them to -generateMaster.plsql
e. generteMaster.plsql uses the 2 date parameters to pass as part of query during the invocation of stored procedure genMDetails(param1, query)
In short - shell script->plsql->stored procedure
Platform is Sun Unix 8, oracle db 9i R2
Thanks.

This script shows how to pass parameters to PL/SQL anonymous block.
sqlplus "mob/mob" << EOF
set serveroutput on
begin
dbms_output.put_line('Parameter one: ' || '$1');
dbms_output.put_line('Parameter two: ' || '$2');
-- Here you can invoke procedure proc1(‘$1’,’$2’);
end;
EOF
You can just invoke it like this:
./passParameters.sh 12-13-1981 03-04-2006
Best Regards
Krystian Zieja / mob

Similar Messages

  • Run shell script from plsql

    You can use utl_tcp to do http posting, send email, and ftp files. Has anyone ever executed a unix shell script from plsql on a remote unix box?

    I am actually asking about running a script file on a remote machine, not on the host. A java procedure or c file extproc call could be used to call a host script file.
    A key limitation of this java procedure method is shown in the ask tom reference:
    if you can do it from sever A on the command line (outside of oracle), we can do
    it inside the database.
    Solve that problem and we'll go from there. Oracle cannot bypass the OS and do
    magical things beyond what you've set up at the OS level.
    since utl.tcp opens a tcp connection, can you open a telnet session using utl_tcp and low level command formatting? I didnt have much trouble creating a plsql based ftp client, has anyone seen a plsql based telnet client?

  • SAP XI: How To Write Shell Script And use it in File Adapter On XI Server

    Hi,
    I want to split file at sender side in XI using Shell Script and then after i want to do
    Mapping.
    Can anyone tell me what exactly it means "write a script in UNIX shell on XI SERVER"?
    Regards,
    Akshay.

    Hi,
    You can execute a Unix script running in the XI server from the File communication channel. Ie. if you want to do something which was not part of XI adapter configuation , then you can make use of external unix script and you can execute those from the XI.
    For this, write a unix script and place in the XI OS level provided that path is accessible from PI Channel.
    E.g
    So u can use this in either Sender Channel to modify the data before it reaches into the Integration Server or in Receiver channel it is generally used to transfer the files into different location via Secure FTP
    SAP help: http://help.sap.com/saphelp_nw2004s/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
    Blog:/people/sameer.shadab/blog/2005/09/21/executing-unix-shell-script-using-operating-system-command-in-xi
    XI  can be in any OS.
    Hope this helps,
    Rgds,
    Moorthy

  • Passing params from SQL file to Shell Script and then from Shell to SQL Fil

    Afternoon guys,
    Have a fun question for all you gurus in shell scripting out there. I have a shell script that is calling 2
    different SQL programs. My objective is to pass a variable called request_number from one sql program
    to the shell script and then from the shell script back to another SQL program. I will explain why I
    need this to happen.
    Here is what the shell script looks like which calls sql programs student_load_a.sql and
    student_load_b.sql. Student_load_a.sql basically creates the control file (.ctl) which is needed for the
    SQL*Loader and then student_load_b.sql reads the table that was just loaded and does the main
    processing. My main objective here is to be passing the request_number which is being generated
    using an Oracle Sequence in student_load_a.sql and using this generated number in my main
    processing in student_load_b.sql to select records from the table based on request_number.
    Any ideas ?Any help or recommendations is welcome and appreciated.
    *1. Shell Script*
    # Accept system input parameters
    p_user_id=$1
    p_job_id=$2
    # Create control files for sqlload
    sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_a.sql $p_job_id
    exit_status=$?
    # Do sqlloads
    sdesqlldr.exe userid=$p_user_id control=student_load-$p_job_id.ctl \
                                                 log=student_load-$p_job_id.log \
                                                 bad=student_load-$p_job_id.bad
    exit_status=$?
    # Main processing
    # sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id $p_request_number
    sqlplus.exe -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id
    exit_status=$?
    exit 0*2. student_load_a.sql (Would like to pass back the Sequence Number back to shell script and then use in student_load_b.sql*
    -- Accept system input parameters
    define p_job_id = &1
    spool student_load-$p_job_id.ctl
    select
    'append into table TMP_STUDENT_LOAD
    FIELDS TERMINATED BY '','' optionally enclosed by ''"''
    trailing nullcols
    (request_number CONSTANT ' || '''' || request_number_seq.nextval || ''',
    student_id)'
    from   dual
    spool off;
    exit 0;
    {code}
    *3. student_load_b.sql (This is a big file so I am only adding code that is relevant for the SQL)*
    {code}
    declare
      v_request_number    number(6);
      v_student_id                  number(7);
      cursor cur_student_load is
        select  student_id
        from   TMP_STUDENT_LOAD
        where  request_number = v_request_number
        order by 1;
    begin
        v_user_id := '&1';
        v_job_id := &2;
        -- This is the variable I would like to be be passing from shell script to student_load_b.sql
        -- v_request_number = '&3';
         open  cur_student_load;
         fetch cur_student_load into v_student_id;
          exit when cur_student_load%notfound;
          .... more logic of if then else in here
         close cur_student_load;
    end;
    {code}
    Edited by: RDonASnowyDay on Jan 29, 2010 4:03 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    How come you are mixing WinDoze script (*.exe) with Unix?
    You are aware that you will be passing the password along with the user id to the second sql script?
    I will assume Unix ksh:
    # Accept system input parameters
    p_user_id=$1
    p_job_id=$2
    # Create control files for sqlload
    p_seqno=`sqlplus -s $p_user_id @$STUDENT_PATH/student_load_a.sql $p_job_id`
    exit_status=$?
    # Do sqlloads
    sqlldr userid=$p_user_id control=student_load-$p_job_id.ctl \
           log=student_load-$p_job_id.log \
           bad=student_load-$p_job_id.bad
    exit_status=$?
    # Main processing
    # sqlplus -s $p_user_id @$STUDENT_PATH/student_load_b.sql $p_user_id $p_job_id $p_request_number
    sqlplus -s $p_user_id @$STUDENT_PATH/student_load_b.sql \
               $p_user_id $p_job_id $p_seqno
    exit_status=$?
    exit 0And the first sql script would look like this:
    -- student_load_a.sql
    -- Accept system input parameters
    set echo off pages 0 feed off lin 80 trims on ver off
    def p_job_id = &1
    col seqno NEW_VALUE seqno
    select request_number_seq.nextval seqno from dual;
    set term off
    spool student_load-$p_job_id.ctl
    select
    'append into table TMP_STUDENT_LOAD
    FIELDS TERMINATED BY '','' optionally enclosed by ''"''
    trailing nullcols
    (request_number CONSTANT ''&&seqno'',
    student_id)'
    from   dual
    spool off;
    exit 0;
    {code}
    :p                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to run 3 job(a,b,c) parallel in unix shells script and after will complete d will start  and we have to handle the error also

    how to run 3 job(a,b,c) parallel in unix shells script and after will complete d will start  and we have to handle the error also

    032ee1bf-8007-4d76-930e-f77ec0dc7e54 wrote:
    how to run 3 job(a,b,c) parallel in unix shells script and after will complete d will start  and we have to handle the error also
    Please don't overwhelm us with so many details!  
    Just off the top of my head ... as a general approach ... something like
    nohup proca
    nohup procb
    nohup procc
    while (some condition checking that all three procs are still running ... maybe a ps -ef |grep  )
    do
    sleep 2
    done
    procd
    But, we'd really need to know what it is you are really trying to accomplish, instead of your pre-conceived solution.

  • Need help with shell scripting and Patching

    Hello all,
    I am a very new Oracle DBA and I just have an interview where i have been ask two questions that i have no idea of what it is
    1/ What is shell scripting and how do you do shell scripting?
    2/ What is Patching and how do you do patching?
    Can some one help to have a very good understanding of these tow questions?
    Thanks a lot

    1/ What is shell scripting and how do you do shell scripting?shell accept command from you (via keyboard) and execute them. But if you use command one by one (sequence of 'n' number of commands) , the you can store this sequence of command to text file and tell the shell to execute this text file instead of entering the commands. This is know as shell script.
    Shell script defined as:
    "Shell Script is series of command written in plain text file. Shell script is just like batch file in MS-DOS
    for example:- for taking backup, health check and doing some task Operating system level or Oracle database level we can create shell script and schedule a cron job
    2/ What is Patching and how do you do patching?for example ,in windows while using sometimes you might face an issue/error and it gives pop up error message would like to send/report this error to microsoft? microsoft will send you a fix for that. lot of fixes for errors/bugs are released as patches.( n number of patches with newer features are releases as new version)
    likewise in oracle for resolving bugs we should have to apply patch.
    patch is basically a fix for a bug/bugs. we need to use opatch utility to apply the paches.
    hope, this helps you

  • Autmator ruby shell script and regex to perform find and replace

    I am trying to create an automator workflow that uses a ruby shell script with regex to replace specified patterns in a text file.
    The following works fine to read (and return) the contents of the specified file:
    original=IO.read(ARGV.join,nil,2)
    changed=original
    puts changed
    However, if then use gsub to remove the word "BENEFICIARY", the action returns the text unchanged:
    original=IO.read(ARGV.join,nil,2)
    changed=original.gsub(/"BENEFICIARY"/,"")
    puts changed
    Using gsub! returns nothing at all.
    Any suggestions?

    This fails due the the spaces in the directory and app name
    Right, this is a common problem that many people encounter.
    I'm guessing I'm placing the single quotes or using the quoted form... improperly. Can someone please explain how to format a path in this manor.
    quoted form is the preferred/recommended way of doing this. Here's an example:
    set cmdPath to "/Users/just me/Desktop/Test Project/Test App.app/Contents/Resources/RWplist"
    do shell script (quoted form of cmdPath) & " --list"
    If you want to build the script manually then you should single-quote the entire path, e.g.:
    do shell script " '/Users/just me/Desktop/Test Project/Test App.app/Contents/Resources/RWplist' --list"
    Note that there are single quotes around the command path but the --list parameter is outside of the single-quoted path.

  • Shell script and escaped spaces

    Recently I decided I should do some backing up of my linux partition and the windows paritition so I decided to use dar with a little script to allow a full backup and a differential backup. The problem is that I have some directory names that have spaces in them and when the dar program is called from the script these become normal spaces and so it doesn't work.
    What should I do? I would rather write the script in ruby but that seems a bit excessive so it would be better to use a shell script.

    The latest issue of linux gazette will be of immense help to you. Sorry it is late where I am & I have to get some sleep. I think it is the answer gang, at the end of their section.
    linuxgazette.net
    There is also freshmeat, which has the latest bash tutorial & ref released within the last couple of days. abs-guide.html.tar.gz

  • Problems using Shell scripts and Automator

    My problem is that when I use the "Run Shell Script" Automator action, it won't work if I type the script inside the action but it will work if I just type a path to the script file, which is less elegant as I then need to copy the Automator app made as well as the script file.
    Here is the script I am trying to use
    #!/bin/bash -f
    if test -f ~/Library/Preferences/SPACE.com/Pro/Registration\ File
    then
    open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
    else
    ditto /Library/Management/Preferences/StarryNight/SPACE.com ~/Library/Preferences/SPACE.com
    open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
    fi
    exit 0

    Well I found the problem. Or at least I got it to work. I tried typing simple commands and scripts into the Shell Script action and had no issues with it running. So I then slowly expanded and typed out my script:
    #!/bin/bash -f
    if test -f ~/Library/Preferences/SPACE.com/Pro/Registration\ File
    then
    open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
    else
    ditto /Library/Management/Preferences/StarryNight/SPACE.com ~/Library/Preferences/SPACE.com
    open -a /Applications/Starry\ Night\ High\ School/Starry\ Night\ High\ School.app/
    fi
    exit 0
    Having typed it out in the script it runs fine. It seems you can't paste text into the action. To test this hypothesis, I copied the working script out of automator into BBedit and then back into Automator, the script no longer worked. Not sure why that is happening, but it does work if I type the scripts out.

  • Shell script from plsql

    Dear all,
    Am trying to call a shell script from sqllplus as below. am getting error IOException .. the file physically exists there and I can execute it from the unix prompt and the permissions are readable,writable and executable for all users,groups
    SQL>
    declare
    k varchar2(2000);
    begin
    TESTS:= comd('devt/test.sh 06753 hi');
    DBMS_OUTPUT.Put_Line(k);
    end; 2 3 4 5 6
    7 /
    IOException ::: devt/test.sh not found/r/n
    PL/SQL procedure successfully completed.
    Any idea?

    Try using DBMS_SCHEDULER
    You need to
    CREATE_PROGRAM
    CREATE_SCHEDULE
    CREATE_JOB
    for ex:
    BEGIN
    DBMS_SCHEDULER.CREATE_PROGRAM(
    program_name => 'testprg',
    program_action => '/me01/tw/scripts/temp/testoratoshell.sh',
    program_type => 'EXECUTABLE',
    comments => 'abc');
    END;
    BEGIN
    DBMS_SCHEDULER.CREATE_SCHEDULE(
    schedule_name => 'testschedule',
    start_date => SYSTIMESTAMP,
    end_date => '31-DEC-16 05.00.00 AM',
    repeat_interval => 'FREQ=DAILY; BYHOUR=4',
    comments => 'Every day at 4 am');
    END;
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'testjob',
    program_name => 'testprg',
    schedule_name => 'testschedule',
    enabled=> true,
    auto_drop=> false
    END;
    /

  • Shell script and keyboard shortcut

    I wrote a bash script, and I would like to start it with a keyboad shortcut, but I can't figure out how to do that. Does anyone know?

    Hi Hugo,
       Keyboard shortcuts are meant for Carbon and Cocoa applications but it can be done; you just have to wrap the shell script in some sort of application. One way is Sveinbjorn Thordarson's Platypus but I just wrap mine with an AppleScript, invoking it with "do shell script". You have to save the AppleScript as an application. Then you open the "Keyboard & Mouse" pane of "System Preferences" and select the "Keyboard Shortcuts" tab. Click the plus sign, '+', pick a key combination and specify your AppleScript or Platypus app as the target.
    Gary
    ~~~~
       Are there those in the land of the brave
       Who can tell me how I should behave
          When I am disgraced
          Because I erased
          A file I intended to save?

  • I need a 2 way sync tool for the mac (or a shell script and some help)

    I am looking for a way to (two way) sync a folder on my Macbook Pro with a SMB Server (aka Windows)
    I found a few paid for applications that do this, and before I buy one I thought I'd ask here and see if there are any recommendations.
    So far I've found Synk Standard and ChronoSync.
    I assume this could also be hacked together with Automator and some shell scripts, but I'm not sure how I'd do that.

    yes, Chronosync is often recommended for this kind of thing. Never heard of Synk Standard. you can also do it for free with rsync but I suggest you stick with Chronosync.

  • Shell scripts and buttons

    i cannot figure out how to get a button made in interface builder/xcode to run/execute a simple shell script. how do i do it. say i made a regular push button named button and i wanted it to start the "fivemin" shell script i pasted in below. assume the shell script is in my path already, do i need to export the path again as well.
    also, my version of xcode is missing the shell script automator fron the new products options, is this a new thing.
    but i would rather do it in a cocoa app. please give me an example say with a timed loop so i can check to see the process running via ps
    ###name: fivemin
    #!/bin/bash
    # this shell script simply sleeps in $incr second intervals for
    # five minutes
    trap 'echo "fivemin: EXITING"' EXIT
    typeset -i nsecs=5*60 i=0 incr=4
    while [ $i -lt $nsecs ]; do
    sleep $incr
    ((i+=incr))
    done
    exit 0

    To wrap a unix tool you need to use NSTask. Here's a useful tutorial from CocoaDevCentral.
    If you're new to Cocoa as you say (in your other post), then I'd first recommend working through a couple of the basic tutorials knocking around to get an idea of the language and the tools available. Apple's own venerable 'Currency Converter' tutorial is here. MacDevCenter's also got quite a few here. You'll be able to find others on the web.
    My version of Xcode (2.1) has a 'Shell Script Automator Action' in the new project assistant, 'Action' section. I've no idea if this has changed in the latest versions, nor why yours might be missing it. The template used when creating it is located in /Application Support/Apple/Developer Tools/Project Templates/Action/Shell Script Automator Action/.
    Another solution that you might consider is using AppleScript Studio. This would use the 'do shell script' command from AppleScript and would use Interface Builder to create your window and button in a similar manner to a Cocoa version.

  • UDM and shell scripts and working with the ENVIRONMENT variable options

    In Userdefined metrics you have the ability to pass envronment variables.
    I was going to send
    DIR=/db/db05/oradata/ORCL/hot
    How to handle whats passed to the shell script?
    It passes $1 as {DIR=/db/db05/oradata/ORCL/hot}
    yes with the brackets. Here I figured it would simply set the DIR environment variable.
    Any cool tricks to work with this mess?
    Is it meant for perl scripts instead?
    Daryl.

    Ilmari Aalto wrote:
    Hi Darth,
    Thanks for your hint! Nevertheless I think it's something more profound, since there's no error etc. For example, should I have the path wrong I assume that OWB would return me some kind of an error when it doesn't find the .sh-file? Isn't there any log-file to see whether the command was executed? It seems like the execution of the User Defined element would be skipped altogether.
    Cheers,
    IlmariNo, if you don't give an absolute path OWB will not return any error, it just wont do anything at all...

  • How to pass a variable to the shell script and crontab?

    Friends,
    here is my script.....
    exp userid=username/password@realdb file=/u02/logical_backup/abc_+$date+.dmp log=/u02/logical_backup/abc_+$date+.log owner=oraadmin statistics=none
    i want the exported file name as abc_2101.dmp and abc_2101.log (2101 is a date and month)
    I want to execute this script daily at 02:00 AM.
    so that i edited the crontab -e as....
    00 02 * * * ./u02/script/dailybkp.sh
    Now what i want is....
    1. is the steps are correct for crontab -e?
    2. Is the script of the crontab will execute daily at 02:00 AM?
    3. how can i rename the .log filename and .dmp file name daily according to the date. for example abc_2001 is today's date and month.how can i replace with the variable.
    thanks
    sathyguy

    sorry....i tested with cp command it was working fine...
    so, i thought it should work for exp command also.
    but its not working....also its not throwing any error....
    the crontab -e is having...
    00 02 * * * exp userid=system/password@realdb file=/u02/test/n22.dmp log=/u02/test/n22.log owner=scott statistics=none
    also i have tested by calling the script.
    #!/bin/bash
    00 02 * * * /u03/script/testbkp.sh
    its not working
    but the below one is working....
    00 02 * * * cp /u02/test.txt /u02/test/test.txt
    also this one is working....
    #!/bin/bash
    00 02 * * * /u03/script/testbkp.sh
    i listed the chkconfig --list crond
    crond 0,1,6 = off
    2,3,4,5 are on
    what might be the reason?
    thanks
    sathyguy

Maybe you are looking for

  • Stock on a particular day

    Hii this is Srikanth, i am working in a product based company, so i need a report details of  "Stock on a particular day". Because, my boss needs, if u give u date he need to get for that day stock for plant wise. for this he is going to enter i.e, i

  • Why did you drop Front Row?  I use my mac as a media centre and apple TV will not work (no DVD control)

    Front Row was an eligant way to access our media files (our nanny, my mom and other non mac users) found it easy.  Apple TV would work but there is no DVD contol so it is out as the mac is our media server. APPLE BRING BACK FRONT ROW!

  • Which ECC table stores shipment # condition type level data?

    Hi all: Here I have a requirement to get freight data at condition type level for each shipment number. Does anybody know which ECC table/field maintain such data? Any post would be appreciated and thank you all in advance! Tim

  • How to remove authorizations for a particular transaction

    Hi, I have an SAP_ALL authorisation for a user. I need to remove authorization for a particular transaction (FK01) for this particular user. How do i make that.

  • Command node inside the dynamic table

    Hi experts, I have a problem regarding on using a command node inside a dynamic table in main window.. I tried inserting a command node in the header of the table then when running my print program i will receive an exception = 2 which is internal er