How Can i get PLSQL Procedure out values in Shell Script?

Hi,
I need to use PLSQL Procedure out values in shell script by using that parameter i need to check and call the other procedure. Please can you guide me how can i?
#!/bin/ksh
# Function to call validation program
SQL_PKG_CALL()
echo "Inside SQL_PKG_CALL for $file"
sqlplus -s /nolog << EOF
     whenever sqlerror exit failure
     connect ${APPS_LOGIN}
     variable exit_value NUMBER
     set serveroutput on size 100000
     DECLARE
          l_errbuf VARCHAR2(10000) := NULL; l_retcode NUMBER := NULL;lv_test VARCHAR2(4000) := NULL;
     BEGIN
          fnd_global.apps_initialize ( USER_ID => ${USER_ID}, RESP_ID => ${RESP_ID}, RESP_APPL_ID => ${RESP_APPL_ID}
                         , SECURITY_GROUP_ID => ${SECURITY_GROUP_ID}
          #Calling PLSQL procedure for create and attache document
          XXAFPEEP_SO_DOC_ATTACH_INT.DOCUMENT_ATTACH (p_errbuf => l_errbuf, p_retcode => :RETMSG, p_fileName => $file
                                   , p_debug => 'Y', p_rettest => lv_test);
          # to print the procedure return values
          DBMS_OUT.PUT_LINE('Return Message: '|| lv_test);
          #${RETCODE}=l_retcode;
          print :RETMSG;
     END;
EXIT 0
EOF
# Program starts here
echo "+---------------------------------------------------------------------------+"
echo "Program Start"
APPS_LOGIN=${1} # Apps Login
USER_ID=${2} # User ID
RESP_ID=${5} # Responsiblity ID
RESP_APPL_ID=${6} # Responsiblity Application ID
SECURITY_GROUP_ID=${7} # Security Group ID
DIRECTORY_PATH=${8} # Directory --Attached file locations
DIRECTORY_NAME=${9} # Directory Name for plsql
echo "User ID : $USER_ID"
echo "Responsibility ID : $RESP_ID"
echo "Responsibilith Application ID : $RESP_APPL_ID"
echo "Security Goup ID : $SECURITY_GROUP_ID"
echo "Directory Path : $DIRECTORY_PATH"
echo "Direcotry Name : $DIRECTORY_NAME"
echo
#files direcotry
cd $DIRECTORY_PATH
echo Present Working Directory: `pwd`
echo
#for all file names
ALL_FILES=`ls *.pdf`
for file in $ALL_FILES
do
     if [ -f $file ]
     then
          #log "Processing $file" # future
          echo Processing: $file
          # Calling the PL/SQL Program
          SQL_PKG_CALL;
          #echo "Retcode : $RETCODE"
          echo "RetMessage : $RETMSG"
     else
          log "Skipped $file: invalid file"
          echo "Skipping current file $file: not a valid file."
     fi
done
Thanks
Sudheer

Saubhik's provided the solution, but just for fun:
Test procedure:
create or replace procedure get_ename
   ( p_empno in emp.empno%type
   , p_ename_out out emp.ename%type )
is
begin
   select ename into p_ename_out
   from   emp
   where  empno = p_empno;
end get_ename;Test data:
SQL> select empno, ename from emp order by 1;
EMPNO ENAME
7369 SMITH
7499 ALLEN
7521 WARD
7566 JONES
7654 MARTIN
7698 BLAKE
7782 CLARK
7788 SCOTT
7839 KING
7844 TURNER
7876 ADAMS
7900 JAMES
7902 FORD
7934 MILLER
14 rows selectedTest call from SQL*Plus to show it working:
SQL> declare
  2     v_ename emp.ename%type;
  3  begin
  4     get_ename(7844,v_ename);
  5     dbms_output.put_line(v_ename);
  6  end;
  7  /
TURNER
PL/SQL procedure successfully completed.Demo shellscript (borrowing the function idea from Saubhik):
#!/bin/ksh
empno=${1:-NULL}
exec_sql() {
    sqlplus -s william/w@//vm.starbase.local:1521/eleven <<END_SQL
    spool get_out_value.sh.log
    set serverout on size 2000 feedback off
    declare
       v_name emp.ename%type;
    begin
       get_ename(${empno},v_name);        
       dbms_output.put_line('# ' || v_name);
    end;
    spool off
    exit
END_SQL
ename=$(exec_sql ${empno} | awk '/^# / {print $2}')
print Employee ${empno} = ${ename}Demo:
/Users/williamr: get_out_value.sh 7844
Employee 7844 = TURNER
/Users/williamr: get_out_value.sh    
Employee NULL =Note this substitutes the word NULL if no empno is passed, and it ignores error output or anything else by only looking for lines beginning '# ' and then taking the following word. Error messages will appear in the logfile. (In this example it probably doesn't need the NULL substitution because a missing parameter would cause a syntax error which the script will handle anyway, but it could be useful in more complex examples.)
For a production script you should probably use an OS authenticated account so you don't have to deal with password strings.

Similar Messages

  • How can I get the best out of my battery life?

    There are a variety of things you can do to extend your device battery life, and use your phone for longer periods of time to see you through the day.
    Set your screen to timeout after a period of inactivity. This way your phone is not sitting idle with the screen backlight consuming extra energy. The recommended screen timeout is 30 seconds, but most phones will allow from 15 seconds to 10 minutes.
    Turn off location services (GPS), Wi-Fi and Bluetooth when not using these functions. When they're on, your phone constantly searches for your current location and open networks, which has a big impact on battery life.
    Turn down the screen brightness. For example, on an iPhone 4 the lowest brightness setting gives roughly 6.5 hours of continuous use, whereas the highest setting gives roughly 3.5 hours. You can always adjust the brightness when you're outside so you can still see your screen clearly. Some devices have an auto-brightness setting, where the phone adjusts the screen brightness depending on the light around it.
    Close your applications. On smartphones, returning to the ‘home' screen only minimises your apps – they keep running in the background. Closing your apps fully will save power; for example, on Samsung Galaxy devices hold down the home button for two seconds to see a list of all open apps. You can then swipe these to the left of the screen to exit them completely. On an Apple product, double press the home button to bring up all active applications and exit from there.

    Re: How can I get the best out of my battery life?
    Hi,
    When I make phone calls people on the other end have difficulty hearing me. They describe as they can hardly hear me as if I was speaking through the pillow etc). I am not touching any buttons and obviously it is not mute. This was happening couple of time in June, then every now and then. Recently it happened a few time in 2 weeks. I was trying to check if it was a reception issue but the place I spoke from is my office I make 70% of phone calls from. Can you book time for me in repair shop and address the issue.
    Thank you.
    Sergey Sinitsyn

  • How can i get HD video out from the lumia 900. ? ...

    How can i get HD video out from the lumia 900. ? Is there some kind of gable. ? N8 has HD cable port..so where is lumia`s port. ?

    Download Zune and start it, when started connect your Lumia 900 and you can now transfer mediafiles from the Lumia to your PC through a USB connection. For Mac use the Mac connector.
    Press the 'Accept As Solution' icon if I have solved your problem, click on the Star Icon below if my advice has helped you!

  • How can I get my data out of a crashed drive?

    I need help. Crashed hard drive. How can I get the data out?

    First have to define what a 'crashed drive' is, so we'll know how to respond.
    If you boot to an installer DVD does Disk Utility see the drive? What does it tell you about the drive?
    If the drive is showing up but not mounting it may be possible to repair it and get the data off yourself -
    But if it isn't even showing up then you may need to take it to a recovery specialist to get the data off it. This is costly and not guaranteed to always work.
    Did you replace the drive in the MBP and install a new OS on a new drive?
    Or is it still in the MBP and you are trying to recover it from there?
    One type of 'crash' is a head crash, usually caused by a impact or jarring to the drive while it is spinning which bounces the heads off the platters. This removes some of the magnetic media off the platters typically rendering it unrecoverable.
    So first priority is tell us precisely where you are with this drive, what you see, what you have tried, what the symptoms are, and what you need to accomplish.
    Rick

  • How can I get my iPhone out of landscape mode and back to portrait?

    How can I get my iPhone out of landscape mode and back to portrait? Tilting the phone doesn't work.

    Try following - 1 by 1:-
    * make sure portrait lock is not on & try turning on/off several times
    * turn off mobile and turned it back on
    * hard reset by pressing lock and home at same time
    If problem persist, you need to try following but be careful since the following impact your iphone.
    * resetting all setting: this will reset all settings of your iphone back to factory setting
    * resetting all setting by erasing all data: this will reset all setting and erase all data so do back-up and proper syncing and read relevant details
    * restoring from itunes: this will also erase all data and take mobile back to day 1
    last 3 options are last resort and only be done if you are sure you can restore your data.
    Please don't hold me responsible for any data loss while doing last 3 options
    Cheers!

  • How can  I get rejected photos out of LR5 and off the HD?

    When I try to deleted rejected photos in LR5 on my iMac, I get a dialog saying they can't be sent to the trash.  How can I get unwanted photos out of LR5 and off the hard drive?

    Instead of hitting just the delete key, you need to hit ⌘+Del and one of the choices will be to remove from hard drive.

  • How can I get more sound out of the Mini?

    How can I get more sound out of theMini?

    Via the headphone jack. That also provides a digitial audio out too. See:
    http://support.apple.com/kb/HT5539

  • How can i get my email out of the file box icon?

    How can I get my email out of the file box icon? Sometimes I touch it by accident and the email message goes in there.

    Another thing to try is renaming it with a .htm or .html extension.
    If that doesn't work either, do you have any other files from your old system? In particular, if you have your old places.sqlite file, you could use that to overwrite your new places.sqlite (bookmarks+history) file.

  • How can I get rid of the values shown on x axis

    How can I get rid of the values shown on x axis ?
    The two diagrams are for illustrations .I want the A diagram like values and wanna get rid of 50 150 250 350on x axis
    Mudassar

    In Axis Options, set Interval to 1. Every category group label
    is displayed. If you want to show every other category group label on the x-axis, type 2.
    "If you want to show every other category group label on the x-axis, type 2."
    what does this mean ?
    when you set 1 as per it everything is shown and when you set 2 every other ????
    Any example on this ?
    Mudassar

  • How can i get apps with out using credit card info because i do not have a card ?

    how can i get apps with out using credit card info because i do not have a card ?

    Yo Chris. I've been following your answers to different threads and quite frankly, you're very keen in answering everybody regarding this stupidity that Apple has brought upon its customers. Kudos to you. But the problem is, most of the time, in some devices, your solution doesn't work because the NONE option is not there. The same goes for me.
    Meanwhile, I found a temporary workaround for the iPhone 4s, iPad 2 and iPod Touch 4th Gen.
    Register a free Apple ID from the iCloud Settings.
    Go to Settings>iCloud>Account>Tap Payment Information on the Storage Plan Category.
    Fill in the other boxes and choose "None" on Credit Card Information.
    That's it! Hope I helped those who still couldn't find the "None" Option.
    Must be running IOS 5.0.1 though, else there would be no iCloud.

  • How can I get a print out of a conversation that was done through text on 08/23/2014?

    how can I get a print out of a conversation that was done through text on 08/23/2014?

    On what kind of phone model? Some phones depending on the OS have SMS Backup applications available.
    You need a court order to get transcripts for the last 6 days or so of text messages directly from Verizon Wireless.

  • How can i get the system language of machine in script

    Hi,
    During postinstall, i want to install file based on the system language.
    How can i get the system language of machine in script ?
    Thanks,

    Michael Conniff wrote:
    I don't get it: what you posted gives a list of all the languages (and I don't see what awk brings to the party).
    Hmm. On my laptop the first bit gets me the list of languages as they appear in the listing in the International preferences pane:
    (en, de, es, ja, fr, it, nl, sv, nb, da, fi, pt, "zh-Hans", "zh-Hant", ko)
    So I piped that to awk to pull out just the first one (they're ordered just like they are in the prefs pane, with the current language first). But that gives me some extra text:
    (en,
    So I piped that to sed to remove the comma and parenthesis. That gives me the current code, which in my case was "en" (or "de" if I switched the language).
    defaults read -g AppleLocale
    gives me en_GB. So maybe this last is better for you?
    Well, sure, if you want to do it the easy way. But where's the fun in that? Seriously though, I get en_US, which is a more accurate and complete view of my settings...
    charlie

  • How can I get settings files out of the Library folder?

    I had to do a clean reinstall (erase & reinstall) to clear up some problems on my Mac. Unfortunately, when you do this, your settings, customizations, bookmarks etc. aren't transferred over as they do when you upgrade in the normal way.
    For example, dashboard widgets are in each user's <home folder>/Library/Widgets folder.
    I could restore some of these settings by dragging the settings files from the old System Folder to the new one. Unfortunately, Apple is making this harder by hiding the Library folder in the user folder, both on the Mac and on the backup drive.
    There is a command to enter in Terminal to show your Library folder, but this only seemed to work on the Mac and not on my backup drive.
    How can I get key settings files out of the Library folder on my backup drive when the Library folder is hidden?
    Thanks

    Open the enclosing folder, choose Go to Folder from the Finder's Go menu, and provide Library as the path.
    (80699)

  • How can i get the h:selectOneRadio value with javascript

    Hi all.
    I have this code
    <h:selectOneRadio id="color" style="font-family: Arial;font-weight:lighter;font-size: 12px" onclick="showColor()" >
    <f:selectItem itemLabel="RED" itemValue="1" />
    <f:selectItem itemLabel="BLUE" itemValue="2" />
    </h:selectOneRadio>
    And javascript function is
    function showColor()
    var tipoRelacion = document.getElementById("form:color").value;
    alert("color" + tipoRelacion);
    And what i get is that color is undefined. How can i get the value of the selected radio?
    Thanks a lot

    you just need to pass this while calling javascript function
    check this-
    <h:selectOneRadio id="color" style="font-family: Arial;font-weight:lighter;font-size: 12px" onclick="showColor(this)" >
    <f:selectItem itemLabel="RED" itemValue="1" />
    <f:selectItem itemLabel="BLUE" itemValue="2" />
    </h:selectOneRadio>
    And javascript function is
    function showColor(obj)
    var val = obj.value
    alert("color" +val);
    }

  • Ibook g4 has died with a dvd inside.  How can I get the dvd out?

    Have an ibook G4 at work. The computer will no longer turn on. Seems like the hard drive has died because the battery is still lighting up. I have a dvd in the computer, though. How can I get it out when the computer won't boot up?

    HI,
    Even though the iBook won't boot, try the suggestions here just in case.
    How to eject your disc
    If you have another Mac and a Firewire cable, you may be able to use Target Disk Mode to eject the disc in the iBook. How to use and troubleshoot FireWire target disk mode
    Carolyn

Maybe you are looking for

  • Cs4 project loaded as desktop mode in cs5

    Hello: Just made the full upgrade yesterday from cs4 to cs5 on windows 7 from vista using the matrox with max.  Loving the HD editing.  I also tried to open an SD cs4 project in cs5.  While opening, and after the message that tells you it is converti

  • I want to highlight various words in a pages document with a yellow or black box behind the text

    I want to use a highlighter in Pages. I know how to do it in steps.. but would like a shortcut to highlight various words throughout the document with a yellow or black box behind the text.. help

  • FileVault and Recovering Data

    I am having a strange issue restoring my data from a Time Machine backup. When I use mirgration assistant it does not allow me to import my identity. It says "********" user cannot be imported because it is encrypted. This encrypted file "my idenity"

  • File permissions on burned CDs and DVDs

    When I burn CDs and DVDs, I often find that the permissions are set such that they are only readable by me. This causes a problem when I go to a Linux machine (or presumably another Mac) with a different login ID. (Interestingly, windows ignores thes

  • Order of starting services in Hyperion System 11.1.1 release

    Hi All, How important is the order of starting services in 11.1.1 ? I mean does this needs to be done manually every time or does Hyperion takes care of this automatically (including dependencies), if I set this to "automatic" in the services panel?