A script-enabled browser is required for this page to function properly.

ORA_FFI.GENERATE_FOREIGN built-in procedure

This 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.

Syntax

PROCEDURE ORA_FFI.GENERATE_FOREIGN
(handle libHandleType);

PROCEDURE ORA_FFI.GENERATE_FOREIGN
(handle libHandleType,
pkgname VARCHAR2);

Parameters

Parameter

Description

handle

A library handle returned by ORA_FFI.LOADLIBRARY or ORA_FFI.FIND_LIBRARY.

pkgname

The name of the package to be generated.

If you do not specify a package name, the name of the library, prefixed with FFI_, is used. For example, if the library name is LIBTEST, the package name will be FFI_LIBTEST.

Usage notes

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.

Example


/* 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;

See also

About the ORA_FFI built-in package

ORA_FFI built-in package