Re: Oracle Foreign Function (ORA_FFI)

From: <suisum_at_freenet.edmonton.ab.ca>
Date: 1996/10/26
Message-ID: <54tqtb$df8_at_news.sas.ab.ca>#1/1


Hi Ganapathy:

I'm very glad that I am not alone. I have asked this question many times and in different forum.

I don't use user_exit function. I use foreign function. It is pretty handy. What I am doing is:

  1. create my DLL.
  2. call the form designer, call the FFIGEN.FMB in: orawin\forms45\demos\foreign directory.
  3. enter the exact parameters and function name, DLL name in the entry form.
  4. compile the library, the library (.PLD) should be the same name as the DLL.
  5. convert the library into binary to get (.PLL) version.
  6. compile the libaray, ans save it.
  7. create a form and attach the package specification and the package body to program unit of your form.
  8. open the package body, find the function call. Reassign the value from export to import variable. *******
  9. compile the form.
  10. execute it.

The point number 8 is the key. Reassign the value. The messagebox in DLL is never worked. I have tried this many times. If someone knows about it, please let me know. I have problem to assign value for datatype LPSTR, please help me also.

The following is my sample codes:

FUNCTION i_ORAWFCreateCaseWithImage(funcHandle IN ora_ffi.funcHandleType ,lpszCaseTitle IN OUT VARCHAR2,
lpszVariableValues IN OUT VARCHAR2,
lpulVariableValues IN PLS_INTEGER,
lpszVariableNames IN OUT VARCHAR2,
lpcVariableTypes IN OUT VARCHAR2,
lpszCaseId IN OUT VARCHAR2),
RETURN PLS_INTEGER;
PRAGMA INTERFACE(C,i_ORAWFCreateCaseWithImage,11265);

FUNCTION ORAWFCreateCaseWithImage
(lpszCaseTitle IN VARCHAR2,
lpszVariableValues IN VARCHAR2,
lpulVariableValues IN PLS_INTEGER,
lpszVariableNames IN VARCHAR2,
lpcVariableTypes IN VARCHAR2,
lpszCaseId IN OUT VARCHAR2)
RETURN PLS_INTEGER IS
lpszCaseTitle_l VARCHAR2(512) := lpszCaseTitle; lpszVariableValues_l VARCHAR2(512) := lpszVariableValues; lpulVariableValues_l PLS_INTEGER := lpulVariableValues; lpszVariableNames_l VARCHAR2(512) := lpszVariableNames; lpcVariableTypes_l VARCHAR2(512) := lpcVariableTypes; lpszCaseId_l VARCHAR2(512) := lpszCaseId; rc PLS_INTEGER;
BEGIN
     rc := i_ORAWFCreateCaseWithImage(fh_ORAWFCreateCaseWithImage ,lpszCaseTitle_l,
lpszVariableValues_l,
lpulVariableValues_l,
lpszVariableNames_l,
lpcVariableTypes_l,
lpszCaseId_l);

  • This is the key. You must reassign value.****

lpszCaseId := lpszCaseId_l;

message('Package body CreateCase lpszCaseId = '|| lpszCaseId); pause;

message('Package body CreateCase lpszCaseId_l = '|| lpszCaseId_l); pause;


RETURN (rc);
END ; BEGIN
     BEGIN

  • You must include .DLL after the library name.****
     lh_ORAWFCAS := ora_ffi.find_library('ORAWFCAS.DLL');
     EXCEPTION WHEN ora_ffi.FFI_ERROR THEN 
     lh_ORAWFCAS := ora_ffi.load_library(NULL,'ORAWFCAS.DLL');
     END ;

Best regards,
Sui-sum

Ganapathy Ramesh (gvramesh_at_ix.netcom.com) wrote:
: I have been quite successful at writing Forms 4.0/4.5 userexits. I am
: now trying to use ORA_FFI built-ins to execute a very simple C DLL
: which receives two LPSTR pointers as parameters. I am simply using the
: MessageBox function in Visual C++ 1.51 to display these parameters. I
: have followed the PL/SQL wrapper example provided with Forms 4.5
: called WINSAMP.FMB/FMX. Though I am able to get upto the call, nothing
: inside the C function seems to execute. The PL/SQL constants I have
: used are C_CHAR_PTR and the starting memory location is 11265. I tried
: compiling the DLL as a large, medium and small memory model, but there
: were no results returned from the DLL. Could anyone out there please
: point out where I might be making a mistake ? Is it possible that the
: DLL I cam creating should be created like an userexit instead of an
: ordinary DLL ? Thanking you iin advance.
 

: G.V.Ramesh

--
Best regards,
Sui-sum

=======================================================================
Sui-sum Fok                        email: suisum_at_freenet.edmonton.ab.ca
                                          suisum_at_compusmart.ab.ca
=======================================================================
Received on Sat Oct 26 1996 - 00:00:00 CEST

Original text of this message