PACKAGE BODY vsa_cod_bar IS /* Declare the library and function handles. */ cod_bar_lhandle Ora_Ffi.Libhandletype ; itf25_fhandle Ora_Ffi.Funchandletype ; /* Create the PL/SQL function that will actually */ /* invoke the foreign function. */ FUNCTION itf25(fhandle Ora_Ffi.Funchandletype, x BINARY_INTEGER) RETURN BINARY_INTEGER; PRAGMA interface(C, itf25, 11265); /* Create the PL/SQL function that is defined in */ /* the package spec. This function simply */ /* passes along the arguments it receives to */ /* itf25 (defined above), prepending the */ /* foreign function handle to the argument List. */ FUNCTION BC_Inter25(x in BINARY_INTEGER) RETURN BINARY_INTEGER IS BEGIN RETURN(itf25(itf25_fhandle, x)); EXCEPTION WHEN Ora_Ffi.Ffi_Error THEN /* print error message */ text_io.put_line(tool_err.message); /* discard the error */ tool_err.pop; END BC_Inter25; /* Define the body of package mathlib */ begin BEGIN /* Load the library. */ cod_bar_lhandle := Ora_Ffi.Load_Library(null,'k.dll'); EXCEPTION WHEN Ora_Ffi.Ffi_Error THEN /* print error message */ text_io.put_line(tool_err.message); /* discard the error */ tool_err.pop; END; begin /* Register the foreign function. */ itf25_fhandle := Ora_Ffi.Register_Function(cod_bar_lhandle, 'BC_Inter25', Ora_Ffi.C_Std); EXCEPTION WHEN Ora_Ffi.Ffi_Error THEN /* print error message */ text_io.put_line(tool_err.message); /* discard the error */ tool_err.pop; END; begin /* Register both parameters of function to_power. */ Ora_Ffi.Register_Parameter(itf25_fhandle,Ora_Ffi.C_INT); EXCEPTION WHEN Ora_Ffi.Ffi_Error THEN /* print error message */ text_io.put_line(tool_err.message); /* discard the error */ tool_err.pop; END; begin /* Register the return type. */ Ora_Ffi.Register_Return (itf25_fhandle, Ora_Ffi.C_INT); EXCEPTION /* Generic FFI Error Handler to unwind the TOOL_ERR stack */ when others then for iCounter in 1..tool_err.nerrors LOOP message(tool_err.message); tool_err.pop; end loop; END; end;