O'Reilly logo

Oracle PL/SQL Programming, Third Edition by Bill Pribyl, Steven Feuerstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing the Call Specification

An external procedure can serve as the implementation of a program unit other than an anonymous block. In other words, a call specification can appear in a top-level procedure or function, a packaged procedure or function, or an object method. What’s more, you can define the call spec in either the specification or the body of packaged program units (or in either the spec or body of object types). Here are some schematic examples:

CREATE FUNCTION name (args) RETURN datatype
AS callspec;

You should recognize the form shown here as that of the shell( ) function shown earlier in the chapter. You can also create a procedure:

CREATE PROCEDURE name
AS callspec;

In this case, the corresponding C function would be typed void.

The next form shows a packaged function that does not need a package body:

CREATE PACKAGE pkgname
AS
   FUNCTION name RETURN datatype
   AS callspec;
END;

However, when the time comes to modify the package, you would have to recompile the specification. Depending on the change you need to make, you may considerably reduce the recompilation ripple effect by moving the call spec into the package body:

CREATE PACKAGE pkgname
AS
   PROCEDURE name;
END;

CREATE PACKAGE BODY pkgname
AS
   PROCEDURE name
   IS callspec;
END;

Unpublished or private program units inside packages can also be implemented as external procedures. Using a call spec in an object type method is quite similar to using it in a package; that is, you can put the call spec in the object type ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required