Skip to Main Content
  • Questions
  • Can we have a package body without a package spec

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question.

Asked: January 26, 2016 - 4:05 pm UTC

Last updated: January 28, 2016 - 1:35 pm UTC

Version: 10.0

Viewed 10K+ times! This question is

You Asked

1)Can we execute package body without package specification?If yes,give me apposite example?

Thanks in Advance.

and Connor said...

No. You must have a spec

SQL> create or replace
  2  package body PPP is
  3
  4    procedure P is begin null; end;
  5
  6  end;
  7  /

Warning: Package Body created with compilation errors.

SQL> sho err
Errors for PACKAGE BODY PPP:

LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0      PL/SQL: Compilation unit analysis terminated
1/14     PLS-00201: identifier 'PPP' must be declared
1/14     PLS-00304: cannot compile body of 'PPP' without its specification


Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

without body

Laurent Schneider, January 28, 2016 - 8:40 am UTC

SQL> create or replace package p is x number; end;
2 /

Package created.

SQL> exec p.x := 1

PL/SQL procedure successfully completed.

We could use a package without body.
Connor McDonald
January 28, 2016 - 1:35 pm UTC

Yep, the opposite isn't true. Thanks Laurent

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library