Sponsored Content
Top Forums Shell Programming and Scripting input stored procedure to shell program Post 302446364 by durden_tyler on Wednesday 18th of August 2010 11:13:14 AM
Old 08-18-2010
Quote:
Originally Posted by tvanoop
...
Looks like unix doesnt like, can someone comment pls
Code:
USERID=scott
PASSWD=xxxxxx
PLSQLCALL=$2
 
STDT=`sqlplus /nolog  <<END >> $LOGFILE
conn ${USERID}/${PASSWD}@${ORACLE_SID}
 
whenever sqlerror exit failure
set serveroutput on timing on lines 150 feedback on
declare
xx varchar2(100);
begin
$PLSQLCALL;
dbms_output.put_line('proc status: '||xx);
if  xx <> 'Success' then
raise_application_error (-20001,'Failed');
end if;
end;
/
exit;
END`

Below execution is error
Code:
./test.sh secload "scott.Pk_Load_proc.Pr_sec_load('SecurityMaster',xx)"
 
Error: Command Line argument is required
Usage: ./test.sh <table name without prefix>

...
Works fine for me. I've cooked up a simple testcase based on your example.

Code:
SQL>
SQL>
SQL> @f7.sql
SQL> --
SQL> drop table t;
 
Table dropped.
 
SQL> drop package pkg_load;
 
Package dropped.
 
SQL> --
SQL> create table t (a number(2), b varchar2(20));
 
Table created.
 
SQL> --
SQL> create or replace package pkg_load as
  2    procedure pr_t_load (t varchar2, x out varchar2);
  3  end;
  4  /
 
Package created.
 
SQL> show errors
No errors.
SQL> --
SQL> create or replace package body pkg_load as
  2    procedure pr_t_load (t varchar2, x out varchar2) is
  3      e_too_big_number exception;
  4      pragma exception_init(e_too_big_number, -1438);
  5    begin
  6      insert into t (a, b)
  7      select rownum, t
  8      from all_objects
  9      where rownum <= 10;
 10      x := 'Success';
 11    exception
 12      when e_too_big_number then
 13        x := 'Failure';
 14    end;
 15  end;
 16  /
 
Package body created.
 
SQL> show errors
No errors.
SQL>
SQL>

Test for success -

Code:
$
$
$ cat -n f7.sh
     1  #!/usr/bin/bash
     2  PLSQLCALL=$2
     3
     4  sqlplus -s test/test <<END
     5  whenever sqlerror exit failure
     6  set serveroutput on timing on lines 150 feedback on
     7  declare
     8  xx varchar2(100);
     9  begin
    10  $PLSQLCALL;
    11  dbms_output.put_line('proc status: '||xx);
    12  if xx <> 'Success' then
    13    raise_application_error (-20001,'Failed');
    14  end if;
    15  end;
    16  /
    17  exit;
    18  END
    19
$
$
$ ./f7.sh secload "test.pkg_load.pr_t_load('SOME_TEXT_HERE', xx)"
proc status: Success
 
PL/SQL procedure successfully completed.
 
Elapsed: 00:00:00.01
$
$

And test for failure -

Code:
SQL>
SQL>
SQL> truncate table t;
Table truncated.
SQL>
SQL> alter table t modify (a number(1));
Table altered.
SQL>
SQL>

Code:
$
$ ./f7.sh secload "test.pkg_load.pr_t_load('SOME_TEXT_HERE', xx)"
proc status: Failure
declare
*
ERROR at line 1:
ORA-20001: Failed
ORA-06512: at line 7

$
$

tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

calling stored procedure from shell script.

Hi All, This is a very starnge problem I am having. I have a shell script that calls a stored procedure. Here's my code in shell script: sqlplus "userid/pwd" @file.sql and file.sql has the following statement: exec my_storedProc; Now, when I execute my shell script, nothing... (2 Replies)
Discussion started by: priyamurthy2005
2 Replies

2. Shell Programming and Scripting

Execute an Oracle stored procedure from a shell scrip

Here is a snippet of my code: if then echo "\n Deleting all reports older than 24 hours. \n" >> $logfile ls -l $FileName >> $logfile ... (1 Reply)
Discussion started by: mh53j_fe
1 Replies

3. Shell Programming and Scripting

Shell arrays in oracle stored procedure

Is it possible to pass unix shell arrays in Oracle stored procedure? Is yes, how? Thanks (6 Replies)
Discussion started by: superprogrammer
6 Replies

4. Shell Programming and Scripting

DB2 stored procedure (with input parameters) from script

I have a db2 stored procedure on my database which require 3 parameters, I have the following db2 command in a sql script CONNECT TO SAMPLE; CALL BACKUP(INPUT_1, INPUT_2, INPUT3); Usually, I would just invoke this sql script from my shell script like below db2 -tf... (1 Reply)
Discussion started by: mpang_
1 Replies

5. Shell Programming and Scripting

Calling stored procedure from shell script

HI, I have a similar problem to thread 18264, only I couldn't get it to work. https://www.unix.com/showthread.php?t=18264 I have a stored procedure which is called by a shell script program. When I run the stored procedure alone or through the shell script, it works fine with output text... (3 Replies)
Discussion started by: dorisw
3 Replies

6. Shell Programming and Scripting

passing parameter 4m shell script to a DB stored procedure

hi all please tell me how to pass parameters 4m shell script to a DataBase stored procedure. To be specific i have sybase DB. i mean i want the syntax of the command.. how to connect to DB, pass user id and password, pass the required parameter to SP.. .. need ur help frnds.. hema (0 Replies)
Discussion started by: hema2026
0 Replies

7. Shell Programming and Scripting

How to execute the stored procedure from shell script

How to execute the stored procedure from shell script and is there any possibility to print the dbms output in a log file. (2 Replies)
Discussion started by: dineshmurs
2 Replies

8. Shell Programming and Scripting

How to call a stored procedure from shell program?

How to call a stored procedure from shell program (1 Reply)
Discussion started by: noorm
1 Replies

9. Shell Programming and Scripting

How to get OUT parameter of a stored procedure in shell script?

I am invoking a SQL script from shell script. This SQL script will invoke a stored procedure(which has the OUT parameter). I want to have the OUT parameter in the shell script as a variable. Is this possible? (6 Replies)
Discussion started by: vel4ever
6 Replies

10. Shell Programming and Scripting

Run stored procedure from shell script

Hello all, I am trying to run stored procrdure from shell script which takes one argument. And also I want to verify in the script whether the script executed successfully. However the Stored procedure is not running from shell script. Manually if I run it update the data in the table. Can... (29 Replies)
Discussion started by: PriyaSri
29 Replies
All times are GMT -4. The time now is 07:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy