Document ID: 40658.1 Subject: NT/95: USER EXITS IN DEVELOPER 2000 Last Modified: 06 Nov 96 Author: Marc Lavergne With the recent release of Developer 2000 rev. 1.3, many people have been asking about how to go about creating user exits with this new release of the developer suite. This article provides a complete user exit which demonstrates the basic functionality of and the procedures involved in creating a user exit. This sample uses the 'EXEC TOOLS' set of calls but could equally use the 'EXEC IAF' set of calls. !!!!!!!!!!!!!!!!!!!!!!!!!! DISCLAIMER !!!!!!!!!!!!!!!!!!!!!!!!!! As of Pro*C 2.2.2.0.0 there is NO OFFICIAL SUPPORT for user exits in Pro*C. This sample ONLY works via Pro*C 2.1 and WILL NOT work if precompiled with Pro*C 2.2.2.0.0. However, there is also NO USER EXIST SUPPORT in Pro*C 2.1. The methods described in this sample will not and cannot be supported by Oracle. In other words, this article should be used as a guideline to facilitate DEVELOPMENT efforts for the first release of Pro*C for NT that will support user exits. This is NOT a certification to proceed with PRODUCTION purposes. OFFICIAL SUPPORT for user exits will be added in the UPCOMING Pro*C 2.2.2.0.1 release. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! /* * *********************************************************** * -------- Worlds most basic User-Exit for WindowsNT -------- * ----------- by: Marc Lavergne (Oracle Support) ------------ * * A User Exit starts off as a normal 'Windows DLL, non-MFC' * project type. All that is required to turn a DLL into a * user exit is the need to add the following files to the * project: F45XTB.DEF, UEZ.OBJ, F45R32.LIB, SQLLIB17.LIB, * and SQXLIB17.LIB and to move/replace the newly created * F45XTB.DLL to C:\ORANT\BIN. * * Remember to do the following: * - Add 'c:\orant\forms45\userexit' to your include directories * - Make F45XTB.DLL the linker output file name * - Add LIB.C and MSVCRT.LIB to the linker's ignore libraries * - Use Pro*C 2.1 and NOT Pro*C 2.2 (unable to resolve sqlctx) * - Move the new F45XTB.DLL to the ORANT\BIN before testing * your user exit. * ************************************************************/ * ************************************************************/ * This is the UE.H as provided with Forms 4.5 which we * must include to define the iapxtb. NB: We -must- also * include 'string.h' and 'sqlca.h' since they are required * for compiling User Exits. * ************************************************************/ #include#include #include "ue.h" EXEC SQL INCLUDE SQLCA; /* * *********************************************************** * This is the iapxtb where we register our user exits 'TESTA' * and 'TESTB' and associate them with their respective functions. * Note the order used in the iapxtb definition: User Exit name, * Function name, and the compiler id which in this case is a * C user exit, thus 'ITCC'. * * In a form PL/SQL block we will call these user exits using * something like: * * begin * user_exit('TESTA'); * end; * * NB: Note the second line which is consecutive 'zero' * entries for User Exit, Function and Compiler names. * This marks the end of the IAPXTB structure. * ************************************************************/ /* Define the user exit functions for the compiler */ int func1(); int func2(); /* Register the user exit functions */ exitr iapxtb[]= { "TESTA", func1, XITCC, "TESTB", func2, XITCC, (char *) 0, 0, 0 }; /* * *********************************************************** * Here's the heart of our code. Basically, there is next to * no difference from a regular Pro*C program from this point * forward. We define our User Exit functions 'func1' and 'func2' * return OK to idicate successful completion. * ************************************************************/ EXEC SQL BEGIN DECLARE SECTION; char deptlocform[55]; char deptlocbuff[55]; EXEC SQL END DECLARE SECTION; int func1() { MessageBox(NULL,"I'm in userexit func1()","Alert",MB_OK); strcpy(deptlocform, "DEPT.LOC"); EXEC IAF GET :deptlocform INTO :deptlocbuff; MessageBox(NULL, deptlocbuff, "In DLL", MB_OK); /* We would return '1' if the result were not sucessful */ return 0; } int func2() { MessageBox(NULL,"I'm in userexit func2()","Alert",MB_OK); strcpy(deptlocform, "DEPT.LOC"); strcpy(deptlocbuff, "MONTREAL"); EXEC TOOLS SET :deptlocform VALUES (:deptlocbuff); /* We would return '1' if the result were not sucessful */ return 0; }