Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to use shell script argumets inside plsql function

2783106Jan 13 2015 — edited Jan 14 2015

Hello all,

I have one query on how to use shell script arguments ($1 $2) , and use these values as input parameters to pkg.function(errmsg,$1,$2);

!#/bin/ksh

function load_iloc

{

   echo "set feedback off

      set heading off

      set serveroutput on size 1000000

      VARIABLE GV_return_code    NUMBER;

      VARIABLE s_loc   NUMBER;

      VARIABLE e_loc   NUMBER;

      VARIABLE GV_script_error   CHAR(600);

      EXEC :GV_return_code := 0;

     

      EXEC :s_loc := $1 ;

      EXEC :e_loc := $2 ;

     

      WHENEVER SQLERROR EXIT 1

      DECLARE

         FUNCTION_ERROR    EXCEPTION;

         L_exist           VARCHAR2(1);

         L_error_type      VARCHAR2(255):= NULL;

         L_err_msg         VARCHAR2(1000);

         L_loc number;

      BEGIN

         if NOT pkg.function(L_err_msg,:s_loc,:e_loc) then

            raise FUNCTION_ERROR;

         end if;

      EXCEPTION

        when FUNCTION_ERROR then

            ROLLBACK;

            :GV_return_code := 1;

            :GV_script_error := L_err_msg;

         when OTHERS then

            ROLLBACK;

            :GV_script_error := L_err_msg;

            :GV_return_code := 1;

      END;

      /

      print :GV_script_error;

      exit  :GV_return_code;

      /" | sqlplus -s ${connectStr} >> ${logFile}

   return $?

}

--------------------------------------------------------------

But this code is not working , kindly do the needful by suggesting a solution.

Thanks

Vijay

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 11 2015
Added on Jan 13 2015
4 comments
340 views