PL/SQL and DLLs
Date: Thu, 29 Oct 1998 10:50:58 -0600
Message-ID: <36389CF2.63E65FB2_at_nospam.com>
Hello,
I am having trouble interfacing with a DLL on WinNT and PL/SQL 2.3.4.0.0
If anyone can help with this in would be great. The error I get is an unknown exception returned from the actual interface call (FF_UP). I cannot debug very well.
The handles to the function and parameter and return types all return with no error.
I have also tried to change the PLS_INTEGER type to NUMBER and INTEGER and I still got the same result.
Thanks in advance,
Michael G. Smith
The code follows
PROCEDURE dll_test IS
rtn_val PLS_INTEGER;
DLL_Handle ora_ffi.libhandletype;
up_handle ora_ffi.funchandletype;
function ff_up (fhandle ora_ffi.funchandletype, i integer)
return PLS_INTEGER;
pragma interface(C, ff_up, up);
function up_one (I pls_integer)
return pls_integer is
begin
Text_Io.Put_Line ('Calling FF_UP routine');
return (ff_up (up_handle, I));
Text_IO.Put_LIne ('** Done calling FF_UP ** ');
EXCEPTION
WHEN ORA_FFI.FFI_ERROR THEN TEXT_IO.PUT_LINE ('*** FFI_Error occured in: UP_ONE function
***');
raise; WHEN OTHERS THEN TEXT_IO.PUT_LINE ('*** Something really BAD happened: UP_ONE
***');
END; BEGIN text_io.put_line('Testing DLL invocation');
dll_handle :=
Ora_Ffi.Load_Library
('C:\Work\C_Work\dllprog\Debug\', 'dllprog.dll');
text_io.put_line('Got LIB handle');
BEGIN
up_handle := ora_ffi.register_function
(dll_handle, 'up_one', ora_ffi.c_std);
EXCEPTION
WHEN ORA_FFI.FFI_ERROR THEN TEXT_IO.PUT_LINE ('*** FFI_ERROR: Could NOT register function
***');
raise; WHEN OTHERS THEN TEXT_IO.PUT_LINE ('*** Unknown Exception: REGISTER FUNCTION
***');
RAISE;
END; text_io.put_line('Got FUNCTION handle');
BEGIN
ora_ffi.register_parameter(up_handle,ora_ffi.c_int);
EXCEPTION
WHEN ORA_FFI.FFI_ERROR THEN TEXT_IO.PUT_LINE ('*** FFI_Error occured in: REGISTER PARAMETER function ***'); raise; WHEN OTHERS THEN TEXT_IO.PUT_LINE ('*** Unknown Exception: REGISTER PARAMETER
***');
RAISE;
END; text_io.put_line ('Registered PARAMETER');
BEGIN
ora_ffi.register_return(up_handle,ora_ffi.c_int);
EXCEPTION
WHEN ORA_FFI.FFI_ERROR THEN TEXT_IO.PUT_LINE ('*** FFI_Error occured in: REGISTER RETURN function ***'); raise; WHEN OTHERS THEN TEXT_IO.PUT_LINE ('*** Unknown Exception: REGISTER RETURN ***'); RAISE;
END; TEXT_IO.PUT_LINE ('Registered Return');
Text_IO.Put_LIne ('**************************');
text_io.put_line ('Making the call to ONE UP'); rtn_val := up_one(10);
text_io.put_line('<=====>'); text_io.put (rtn_val); text_io.new_line; text_io.put_line('<=====>');
text_io.put_line ('*** === > Done!! < === ***');
EXCEPTION
WHEN ORA_FFI.FFI_ERROR THEN
TEXT_IO.PUT_LINE ('*** Could NOT register function ***');
WHEN OTHERS THEN
TEXT_IO.PUT_LINE ('*** Something really BAD happened ***');
END DLL_TEST;
Received on Thu Oct 29 1998 - 17:50:58 CET