ORA_FFI.GENERATE_FOREIGN
built-in procedureThis procedure generates a package of PL/SQL code for all the functions defined in the specified library. You must first load the library, register all of the functions you want to invoke, and register their parameter and return values.
PROCEDURE ORA_FFI.GENERATE_FOREIGN
(handle libHandleType);
PROCEDURE ORA_FFI.GENERATE_FOREIGN
(handle libHandleType,
pkgname VARCHAR2);
Parameter |
Description |
|
A library handle returned by |
|
The name of the package to be generated. If you do not specify a package name, the name of the library, prefixed
with |
Packages generated by the ORA_FFI.GENERATE.FOREIGN
function are created in your current name space and will appear under the
Program Units node of the Procedure Builder Object Navigator. Once a package
has been generated, you can copy it to the Program Units node of a PL/SQL
Library or to the Stored Program Units node of a database, and you can export
it to a text file using FileExport,
just like any other new package or procedure that you have defined.
A PL/SQL package generated by the ORA_FFI.GENERATE.FOREIGN
function automatically includes the required PRAGMA compiler directives
for each of the registered functions:
PRAGMA interface (C, func_name, 11265);
where func_name
is the name of a registered
foreign function from a dll library that has already been loaded. You can specify
the name of the generated PL/SQL package, but within that package, each of the
entry points will match the names of the foreign functions they map to.
/* Define components of package test */
PACKAGE test IS
...
END;
/*Define package body procedures */
PACKAGE BODY test IS
PRODEDURE register_libs IS
BEGIN
/* Load the test library */
testlib_lhandle := ORA_FFI_.LOAD_LIBRARY
('c:\orawin95\oralibs\','testlib.dll')
END;
PROCEDURE define_c_funcs IS
getresult_fhandle ORA_FFI.FUNCHANDLETYPE;
foo_handle ORA_FFI.FUNCHANDLETYPE;
BEGIN
/* Register the info for function getresult */
getresult_fhandle := ORA_FFI.REGISTER_FUNCTION
(testlib_lhandle,'getresult');
...
/* Register the info for function foo */
foo_fhandle := ORA_FFI.REGISTER_FUNCTION
(testlib_lhandle,'foo');
...
/* Generate PL/SQL package containing all
functions defined in test library */
ORA_FFI.GENERATE.FOREIGN
(testlib_lhandle, 'test_ffi_pkg');
...
END;
END;
About the ORA_FFI
built-in package
Copyright © 1984, 2005, Oracle. All rights reserved.