B. Building Encina Programs on UNIX : How You Build Programs for Encina : Step 3: Create the Encina Code
 
Share this page                  
Step 3: Create the Encina Code
To create an Ingres DTP-compatible application program, you must observe the following requirements when coding:
1. Your application must include the “iixa.h” file provided by Ingres. For example, in a C program, use the following code:
#include <iixa.h>
2. Your application must include an SQLCA for error trapping; use the following embedded SQL code:
exec sql include sqlca;
3. Your application must use Encina's mon_InitResourceManager function to initialize each Ingres database to which it requires access. The argument to the mon_InitResourceManager function must be the resource manager name you specified in the monadmin command.
4. In applications that access multiple resource managers, use the Ingres SQL set connection statement to specify the resource manager you want to access. The connection name must be the connection name specified in the open string. For example:
void check_inventory (...)
{
exec sql set connection 'inventory';
Perform database access
5. Encina requires your application server to provide a server_Init function that initializes application servers. For details about server_Init, refer to the Encina Monitor Programmer's Guide. The following code illustrates the framework of a typical server_Init function:
# include <xa.h>
# include <iixa.h>
void server_Init(argc, argv)
int argc;
char *argv[];
{
...
/* register resource mangers */
mon_ServerRecoverable();
if (mon_InitResourceManager(&iixa_switch, "inventory")) != MON_SUCCESS)
{
     handle error routine
}
if (mon_InitResourceManager(&iixa_switch, "billing"))
 != MON_SUCCESS)
{
        handle error routine
}
...
}
If your application registers for more than one resource manager, your service routines must issue the SQL set connection statement (to establish which RMI they are accessing) before performing any database access.