Oracle Libraries
Version 12.1.0.1

General Information
Library Note Morgan's Library Page Footer
The Library is currently in the process of being upgraded from Oracle Database Version 11.2.0.3 to 12.1.0.1. Demos are being upgraded to reflect the new Container paradigm as well as EBR (Edition Based Redefinition) and may contain references to CDBs, PDBs, and other objects you may not be familiar with such as CDB_OBJECTS_AE: Welcome to 12c.
Purpose A library is a schema object associated with an operating-system shared library: For example a DLL.

You can use the name of the library schema object in the call specification (call_spec) of a CREATE FUNCTION or CREATE PROCEDURE statements, or when declaring a function or procedure in a package or type, allowing the function, package, procedure, or type to invoke a 3GL code in the library.
Dependencies
ALL_LIBRARIES DBA_LIBRARIES LIBRARIES$
CDB_LIBRARIES INT$DBA_LIBRARIES USER_LIBRARIES
System Privileges
ALTER ANY LIBRARY CREATE LIBRARY EXECUTE ANY LIBRARY
CREATE ANY LIBRARY DROP ANY LIBRARY  
Document Sections
 
CREATE LIBRARY
Create Library CREATE OR REPLACE [<EDITIONABLE | NONEDITIONABLE>] LIBRARY <[schema_name.]library_name> [TRUSTED] <AS | IS>
STATIC;
conn uwclass/uwclass@pdbdev

CREATE OR REPLACE LIBRARY morgan AS STATIC;
/

CREATE OR REPLACE LIBRARY morgan TRUSTED AS STATIC;
/
Create a library with a hard-coded pointer (not recommended)  
CREATE OR REPLACE LIBRARY ext_lib AS '/OR/lib/ext_lib.so';
/
Create a library with a directory object pointer CREATE OR REPLACE LIBRARY <[schema_name.]library_name> AS <executable_nam,e> IN <directory_object_name>;
CREATE OR REPLACE DIRECTORY ext_code_dir AS 'c:\tmp';

CREATE OR REPLACE LIBRARY ext_lib AS 'morgan.so' IN ext_code_dir;
/
Create a library with a directory object pointer and a credential  
CREATE OR REPLACE LIBRARY ext_lib AS 'morgan.so' IN ext_code_dir CREDENTIAL uwcred;
/
Create Library with credenital and calling function CREATE OR REPLACE [<EDITIONABLE | NONEDITIONABLE>] LIBRARY <[schema_name.]library_name> <AS | IS>
'<full_path_name>' [AGENT '<agent_dblink_name>'] CREDENTIAL <[schema_name.]credential_name>;
conn uwclass/uwclass@pdbdev

DECLARE
 cname   user_credentials.credential_name%TYPE := 'UWCRED';
 uname   user_credentials.username%TYPE := 'UWCLASS';
 pwd     sys.scheduler$_credential.password%TYPE := 'ZzYzX6*';
 dbrole  VARCHAR2(30) := NULL;
 windom  sys.scheduler$_credential.domain%TYPE := NULL;
 comment user_credentials.comments%TYPE := 'Test Cred';
 enable  BOOLEAN := FALSE;
BEGIN
  dbms_credential.create_credential(cname, uname, pwd, dbrole, windom, comment, enable);
END;
/

SELECT credential_name
FROM user_credentials;

CREATE OR REPLACE LIBRARY morgan AS
'/app/oracle/ext_procs/morgan.so' CREDENTIAL uwcred;
/

CREATE OR REPLACE FUNCTION ftest1 (x VARCHAR2, y BINARY_INTEGER) RETURN BINARY_INTEGER AUTHID DEFINER
AS LANGUAGE C
LIBRARY morgan
NAME "iterate_x"
PARAMETERS(x STRING, y INT)
;
/
Create Library with Agent CREATE OR REPLACE [<EDITIONABLE | NONEDITIONABLE>] LIBRARY <[schema_name.]library_name> <AS | IS>
'<full_path_name>' AGENT '<agent_dblink_name>';
CREATE OR REPLACE LIBRARY morgan AS
'${ORACLE_HOME}/lib/morgan.so'
AGENT 'uwagent.mlib.org';
/
 
ALTER LIBRARY
Editionable / Noneditionable ALTER LIBRARY <[schema_name.]library_name>  <EDITIONABLE | NONEDITIONABLE>;
ALTER LIBRARY morgan EDITIONABLE;
Recompile ALTER LIBRARY <[schema_name.]library_name>  COMPILE [DEBUG] <parameter_name> = <parameter_value> [REUSE SETTINGS];
ALTER LIBRARY morgan COMPILE REUSE SETTINGS;
 
DROP LIBRARY
Drop a library object DROP LIBRARY <[schema_name.]library_name>;
DROP LIBRARY morgan;

Related Topics
Directories
DBMS_CREDENTIAL
Functions
Packages
Procedures
Types

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2014 Daniel A. Morgan All Rights Reserved