Solved

SQL*Plus Syntax for calling Stored Procedure (some have IN Parameters , some don't)

Posted on 2004-08-02
5
11,428 Views
Last Modified: 2010-10-05
Thru the SQL*Plus client's console  I am able to execute  the Open SQL below:
   select * from user_objects where object_type = "PACKAGE";

I can also execute the JLOs_Proc1 and JLOs_Proc1 Stored Procs below (from a VC++ client application)

?
How do I call the JLOs_Proc1 and JLOs_Proc1 Stored Procs from the SQL*Plus  prompt
?

create or replace package JLOs_pkg is
type genericCursor is ref cursor;
end JLOs_pkg;
/
create or replace procedure JLOs_Proc1 ( sp_cursor OUT JLOs_pkg.genericCursor )
is
begin
open sp_cursor  for select * from user_objects;
end;
/
create or replace procedure JLOs_Proc2 ( prm_1 IN varchar2, sp_cursor OUT JLOs_pkg.genericCursor )
is
begin
open sp_cursor  for select * from user_objects where object_type = prm_1 order by created;
end;
/
create or replace procedure JLOs_Proc3 ( prm_1 IN varchar2, prm_2 IN number, sp_cursor OUT JLOs_pkg.genericCursor )
is
begin
open sp_cursor  for select * from user_objects where object_type = prm_1 and object_id = prm_2;
end;
0
Comment
Question by:jjlloorrttiizz
5 Comments
 
LVL 23

Expert Comment

by:seazodiac
ID: 11697321
in sqlplus window, you call stored procedure in one of two ways;


BEGIN
<procedure_name with params>;
END;
/

or

execute <procedure_name with params>;

0
 
LVL 34

Expert Comment

by:Mark Geerlings
ID: 11698089
Yes, seazodiak gave you the syntax for executing PL\SQL procedures from SQL*Plus.  To execute functions, the syntax is slightly different (you just list them in a select statement like you would list a column name), but I am not sure that SQL*Plus supports executing stored procedures that return ref cursors.  In SQL*Plus, I would normally just execute the select statement directly, and not try to add the PL\SQL layer in between.
0
 
LVL 7

Accepted Solution

by:
BobMc earned 60 total points
ID: 11698573
I run most of my reports this way, so I get the flexibilty of PL/SQL to generate the data sets, and the (often under-rated) built in report formatting capabilities of SqlPlus


From SqlPlus:

VARIABLE bob REFCURSOR;

EXECUTE JLOs_Proc1 (:bob);

PRINT :bob;


HTH
Bob
0
 
LVL 22

Assisted Solution

by:earth man2
earth man2 earned 40 total points
ID: 11698631
SQL> create or replace procedure JLOs_Proc3 ( prm_1 IN varchar2, prm_2 IN number, sp_cursor OUT sys_refcursor )
is
begin
open sp_cursor  for select * from user_objects where object_type = prm_1 and object_id = prm_2;
end;
/
SQL> variable cur refcursor;
SQL> execute JLOs_Proc3('JAVA SOURCE',38877, :cur );
SQL> print cur;

dmf_fnd_ww_dirList
                                    38877                JAVA SOURCE
16-JUL-04 17-JUL-04 2004-07-17:00:25:54 VALID   N N N
0
 

Author Comment

by:jjlloorrttiizz
ID: 11698897
Thanks Bob, for the sample code for the Proc that takes no In parms (It worked the first time)

Thanks earthman2, for the sample code for the Proc that takes In parms (It worked the first time, after I plugged in values for my environment)

- This is my first - I hope I followed correct EE Protocol, regarding splitting points and accepting the first correct comment/answer...
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Pl/SQL Query 31 62
Oracle RMAN Database Restore 5 32
statspack purge automate 7 30
compre toata in where clue oracle 4 44
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now