Writing a User Exit in Microsoft Windows
To create a foreign function that can be invoked from a user exit on Microsoft Windows:
- Write a foreign function using Pro*C and Oracle precompiler statements to
access the database.
For example, create a text file called UEXIT.PC, then add the following text:
/* UEXIT.PC file */
/* This foreign function adds an ID column to the EMP table. */
#ifndef UE
#include "ue.h"
#endif
#ifndef _WINDLL
#define SQLCA_STORAGE_CLASS extern
#endif
EXEC SQL INCLUDE sqlca.h
void AddColumn() {
EXEC SQL alter table EMP add ID varchar(9);
}
- Precompile the foreign function with an Oracle precompiler (Pro*C precompiler).
For example, use Pro*C to precompile the UEXIT.PC file. When you precompile
UEXIT.PC, Pro*C
creates a C file called UEXIT.C.
- Create your header files.
Your header file must define your foreign function. For example, modify the
sample header file, UE.H, by adding the
following text:
extern void AddColumn();
- Compile UEXIT.C to generate a foreign
function object code file. Be sure to specify the large memory model on your
compiler.
- Create the IAPXTB control structure.
- Modify the file UE_XTB.C file by including
the UEXIT.H file and adding the user exit
name, foreign function name, and language type. Follow the example in the
UE_XTB.C file. In this case, the following
entry is added to the file:
Add_ID_Column, AddColumn,
XITCC
- Modify any required foreign function integration files.
- Modify the UE_SAMP.DEF file by adding
export statements to include the AddColumn
foreign function. Follow the examples in the UE_SAMP.DEF
file.
- Build a DLL for use with Forms Runtime.
- With the exception of UEXIT.C,
the following files should already be included in the UE_SAMP.MAK
project file:
<oracle_home>/forms/userexit/uez.obj
<oracle_home>/forms/userexit/osswep.obj
<oracle_home>/forms/userexit/ue_samp.def
<oracle_home>/forms/userexit/ue_xtb.c
<oracle_home>/forms/userexit/uexit.c
The UE_SAMP.MAK project is set up to link
the following files:
LIBC.LIB
OLDNAMES
<oracle_home>/forms/userexit/frmr.LIB
<oracle_home>/pro20/userexit/sqllib18.lib
<oracle_home>/pro20/userexit/sqxlib18.lib
- After building the UE_SAMP.MAK project,
the result is a DLL named UE_SAMP.DLL. Add
the UE_SAMP.DLL entry to the List of DLLs
defined by the FORMS_USEREXITS parameter
in the registry.
Alternatively, you can rename UE_SAMP.DLL
to FRMXTB32.DLL, backup the FRMXTB32.DLL
in the <oracle_home>/bin directory, and copy the new FRMXTB32.DLL
to the <oracle_home>/bin directory.
- Make sure you include the name of the DLL in the FORMS_USEREXITS
variable in the registry, or rename the DLL to FRMXTB32.DLL.
If you rename the DLL to FRMXTB32.DLL, replace
the existing FRMXTB32.DLL in the <oracle_home>/bin
directory with the new FRMXTB32.DLL.
- Invoke the foreign function from a user exit in Oracle
Forms.
In this case, a When-Button-Pressed Trigger calls the foreign function from
a user exit. The following statement demonstrates how to invoke the AddColumn
foreign function by specifying the user exit name Add_ID_Column
in the USER_EXIT Built-in subprogram:
/* Trigger: When-Button-Pressed */
USER_EXIT('Add_ID_Column');
Related topics
Compiling Microsoft Windows foreign
functions
Microsoft Windows user exit interface files
About writing a user exit on Microsoft Windows