Syntax for External Procedures

Now that we've gone through the basic steps and seen examples of the kind of code you must write in order to take advantage of external procedures, let's explore each syntactic element in more detail.

CREATE LIBRARY: Creating the External Procedure Library

Step 3 in the random number generator example we presented in the previous section uses the SQL statement CREATE LIBRARY. The general syntax for this command is:

CREATE [ OR REPLACE ] LIBRARY <library name> AS '<path to file>';

Where:

Here are some things to keep in mind when issuing a CREATE LIBRARY statement:

EXTERNAL: Creating the PL/SQL Body

In lieu of a BEGIN..END block, the body of your PL/SQL function or procedure must contain an EXTERNAL clause. This section describes the content of this clause. Syntactically, it looks like this:

EXTERNAL LIBRARY <library name> [ NAME <external routine name> ] [ LANGUAGE <language name> ] [ CALLING STANDARD C | PASCAL ] [ PARAMETERS (<external parameter list>) ] [ WITH CONTEXT ];

Where:

DROP: Dropping Libraries

The syntax for dropping a library is simply:

DROP LIBRARY <library name>;

The Oracle user who executes this command must have the DROP LIBRARY or DROP ANY LIBRARY privilege.

Oracle does not check dependency information before dropping the library. This is useful if you need to change the name or location of the shared object file to which the library points. You can just drop it and rebuild it, and any dependent routines will continue to function. (More useful, perhaps, would be a requirement that you use a DROP LIBRARY FORCE command, but such an option does not exist).

Before you drop the library permanently, you'll probably want to look in the DBA_DEPENDENCIES view to see if any PL/SQL module relies on the library.