Invoking SP through Anonymous Block


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Invoking SP through Anonymous Block
# 1  
Old 08-26-2011
Invoking SP through Anonymous Block

Hi,

I'm writing a Shell script to run a stored procedure through SQL*Plus using the below script and it works well.

Test.sh
$ORACLE_HOME/bin/sqlplus
connect user/pwd@dbname
@Test.sql

Test.sql
call sp_test_procedure()

Now, similarly I want to run the below PL/SQL anonymous block from shell script. I'm not sure how to do this and what is the syntax. Please share your thoughts, thank you.

DECLARE
I_Parm1 VARCHAR2(200);
I_Parm2 VARCHAR2(200);
I_Parm3 VARCHAR2(200);
BEGIN
I_Parm1 := 'Data1';
I_Parm2 := 'Data2';
I_Parm3 := 'Data3';
SP_Test(
I_Parm1 => I_Parm1,
I_Parm2 => I_Parm2,
I_Parm3 => I_Parm3
);
END;
/
# 2  
Old 08-26-2011
Try if the below on works. Or similarly you can place the anonymous block inside file Test.sql and run as you tried in post# 1. Did you try this way..?
Code:
#!/bin/ksh
user="myUser"
passwd="werwe"
DB="myDB"

$ORACLE_HOME/bin/sqlplus -s $user/$passwd@DB << EOF
set verify off
set heading off
set feedback off
DECLARE
I_Parm1 VARCHAR2(200);
I_Parm2 VARCHAR2(200);
I_Parm3 VARCHAR2(200);
BEGIN
I_Parm1 := 'Data1'; 
I_Parm2 := 'Data2';
I_Parm3 := 'Data3';
SP_Test(
I_Parm1 => I_Parm1,
I_Parm2 => I_Parm2,
I_Parm3 => I_Parm3
);
END;
/
EOF

This User Gave Thanks to michaelrozar17 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Call Anonymous block from DB2

Hi, I have a shell script and im trying to call a .sql file. The sql file has a simple Anonymous block. The code is shell script db2 -tvf query.sql the sql file contains SET SERVEROUTPUT ON; BEGIN call dbms_output.put_line( 'Hello' ); END; I get the following error BEGIN... (1 Reply)
Discussion started by: sup
1 Replies

2. Shell Programming and Scripting

Passing the result of an anonymous pl/sql block to a shell script

Hello, Here is the code i have written to get the count of a plsql query back to the unix. function checkforCOIDs { countcheck=`sqlplus -s $1/$2@$3 whenever oserror exit sql.oscode rollback whenever sqlerror exit sql.sqlcode rollback set serverout on size 2000; set head off feedback off... (2 Replies)
Discussion started by: santosh2eee
2 Replies

3. Shell Programming and Scripting

Calling an Anonymous Block through shell script

Hi, My requirement is to load a LONG datatype data value from one table to another as direct access does not work (DB: ORACLE). eg. SELECT *FROM ALL_VIEWS WHERE TEXT LIKE '%<SEARCH_STRING>%'; As an alternate we are creating a table and trying to insert in it from ALL_VIEWS as direct insert... (2 Replies)
Discussion started by: sanjaydubey2006
2 Replies

4. What is on Your Mind?

New Forum for Anonymous Posters

Just created an experimental new forum for anonymous posters. Anonymous Users Forums - The UNIX and Linux Forums Feel free to comment about it here. (2 Replies)
Discussion started by: Neo
2 Replies

5. Shell Programming and Scripting

To get value from Oracle Anonymous PLSQL block

Hi All, i need you help while accessing the value from anonymous PL/SQL block. Initially our requirement was to get the value from SQL statement. I was doing like... But now i need to use dbms_application_info.set_module in it. So i have planned to use anonymous block instead of SQL... (2 Replies)
Discussion started by: Amit.Sagpariya
2 Replies

6. UNIX for Dummies Questions & Answers

How to block an anonymous ftp user?

Could anyone provide information on how to block a specific client machine from being able to log onto anonymous ftp? (10 Replies)
Discussion started by: dennisheazle
10 Replies

7. Cybersecurity

anonymous ftp attack?

For the last week or so every day for about 6 to 10 hours someone is logging in and out continuously to our anonymous ftp. They don't stay logged in. It seems like it must be an automatic process aimed at tying up our anonymous ftp. The ID of the server doing this is can59-4-82-240-1. As a result... (2 Replies)
Discussion started by: dennisheazle
2 Replies

8. UNIX for Advanced & Expert Users

Anonymous User

Hi, Can a anonymous user have password ? I have created a user and set password. Now I want to create that user as anonymous. Ronald (1 Reply)
Discussion started by: ronald_brayan
1 Replies
Login or Register to Ask a Question