Writing the Call Specification
An external procedure can serve as the implementation of any 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 FUNCTIONname
(args
) RETURNdatatype
AScallspec
;
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 PROCEDUREname
AScallspec
;
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 PACKAGEpkgname
AS FUNCTIONname
RETURNdatatype
AScallspec
; 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 PACKAGEpkgname
AS PROCEDUREname
; END; CREATE PACKAGE BODYpkgname
AS PROCEDUREname
AScallspec
; END;
Unpublished or private program units inside packages can also be implemented as external procedures. And finally, 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 ...
Get Oracle PL/SQL Programming, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.