-3

I'm unable to execute procedures and packages in TOAD. Could anybody please help me out. How to execute the procedure and packages Give me some key points

Oddmar Dam
  • 719
  • 9
  • 26
manikanta
  • 1
  • 1
  • Hi Manikanta. What have you tried so far? I'm not familiar with TOAD but i want to help you formulate your question so that you can get a good answer: Please read this for guidelines on using stackoverflow: https://stackoverflow.com/help/how-to-ask – Oddmar Dam Jun 14 '19 at 05:09

1 Answers1

0

TOAD (originally) = Tool for Oracle Application Developers.

Nowadays, there are TOAD versions for other DBMS's. "Procedures and packages" sound very much like "database". So, what is C# tag doing here?

As of Oracle: the right way to run a stored procedure is to enclose its name into BEGIN-END block, provide parameters (if any; both IN and OUT included) and run it as a script (F9 on the keyboard).

For example:

-- create a procedure
create or replace procedure p_test_1 (par_empno in emp.empno%type) is
begin
  null;
end;

-- run it in TOAD
begin
  p_test_1(1234);
end;

If there's an OUT parameter, you'll have to declare a variable to accept it:

-- create a procedure
create or replace procedure p_test_2 (par_empno  in emp.empno%type,
                                      par_ename out emp.ename%type) is
begin
  select e.ename 
    into par_ename
    from emp e
    where e.empno = par_empno;
end;

-- run it in TOAD
declare
  l_ename emp.ename%type;
begin
  p_test_1(1234, l_ename);
end;

The same - but really the same - goes for procedures/functions that belong to packages. The only difference is that you'd have to precede procedure's name with the package name. For example:

-- create a package specification
create or replace package pkg_test is
  procedure p_test_1;
end;

-- create a package body (with all its procedures, functions, ...)
create or replace package body pkg_test is
  procedure p_test_1 is
  begin
    null;
  end;
end;

-- call it 
begin
  pkg_Test.p_test_!;
end;
Littlefoot
  • 131,892
  • 15
  • 35
  • 57