3

There is a package ABC and many procedures inside it. I want to execute a single procedure inside that (say xyz). I used the below commands

begin
ABC.xyz;
end;

I am not able to run the same. Can any one help as I am getting Unexpected symbol "BEGIN" error

Ravi
  • 30,829
  • 42
  • 119
  • 173
Ramanathan K
  • 1,829
  • 3
  • 13
  • 8

3 Answers3

4

Create Package specification :

create or replace package pkg is
procedure xyz;
end;

Create Package body :

create or replace package body pkg is
procedure xyz is
dbms_output.put_line('hi');
end
end;

Executing

exec pkg.xyz

OR

begin
pkg.xyz;
end;

Now, verify your code and see what have you done wrong in your code.

Ravi
  • 30,829
  • 42
  • 119
  • 173
2

I want to execute a single procedure inside that (say xyz)

You can call a procedure from a package onnly if you have added it to the package specification.

From documentation,

The package spec contains public declarations. The scope of these declarations is local to your database schema and global to the package. So, the declared items are accessible from your application and from anywhere in the package.

Once you add the procedure to the package spec, you could then call your procedure as package.procedure in a PL/SQL block:

begin
   ABC.xyz;
end;

Or, in SQL*Plus:

EXECUTE ABC.xyz;
Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124
0

To add to the great answers above: In some cases, the package is only accessible via a specific user account. In out setup we have admin and app users that have access to specific schemas and data so that our applications share a single Oracle installation. Just add the user name where your package and tables are stored.

begin user.pkg.xyz; end;

turbogeek
  • 130
  • 9