Solved

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

Posted on 2004-08-02
5
11,429 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 35

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

911 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

21 Experts available now in Live!

Get 1:1 Help Now