Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle: Call stored procedure inside the package

Tags:

I'm not much in Oracle. I use PL/SQL Developer.

I have the following package:

create or replace package PKG1
as
procedure INIT
(
  nRN                       in number,
  nREC_TYPE                 in number,
  nIDENT                    out number
);

I'm not sure how to call it from PL/SQL Developer environment. I've tried this:

DECLARE
  procId NUMBER;

BEGIN
  EXECUTE PKG1.INIT(1143824, 0, procId);
  DBMS_OUTPUT.PUT_LINE(procId);
END;

But, there's an ORA-06550 (PLS-00103) error.

As you can see I have 2 input and 1 output parameter. I want to print out output parameter. That's all.

Thanks in advance for help.

Goran

like image 630
tesicg Avatar asked Oct 23 '12 08:10

tesicg


People also ask

How can I grant execute to a procedure inside a package?

You cannot grant execute on a procedure inside a package. You can grant execute to the whole package only.

Can we call a stored procedure inside a function in Oracle?

You can call a stored procedure inside a user-defined function.

Can you alter procedure within package?

Because all objects in a package are stored as a unit, the ALTER PACKAGE statement recompiles all package objects. You cannot use the ALTER PROCEDURE statement or ALTER FUNCTION statement to recompile individually a procedure or function that is part of a package.


2 Answers

You're nearly there, just take out the EXECUTE:

DECLARE
  procId NUMBER;

BEGIN
  PKG1.INIT(1143824, 0, procId);
  DBMS_OUTPUT.PUT_LINE(procId);
END;
like image 92
cagcowboy Avatar answered Sep 24 '22 20:09

cagcowboy


To those that are incline to use GUI:

Click Right mouse button on procecdure name then select Test

enter image description here

Then in new window you will see script generated just add the parameters and click on Start Debugger or F9

enter image description here

Hope this saves you some time.

like image 31
Matas Vaitkevicius Avatar answered Sep 23 '22 20:09

Matas Vaitkevicius