Programming Guide



ONENTRY

Installs an entry handler

Synopsis

DBMS ONENTRY CALL function
DBMS ONENTRY JPL jplEntryPoint
DBMS ONENTRY STOP

Arguments

CALL function
Name of prototyped function.

JPL jplEntryPoint
Name of JPL procedure.

STOP
Remove any installed entry handler.

Use DBMS ONENTRY to install a function or JPL procedure which Panther calls before it executes each DBMS statement.

This function is for informational purposes only. For instance, you can log statements to a text file before executing them. You can use this function with an exit function to track the start and end time for a query or any other database operation.

The function is passed three arguments:

  1. A copy of the first 255 characters of the statement; if the statement is executed from JPL, this is the first 255 characters after the command word DBMS or DBMS SQL.
  2. The name of the database engine for the statement.
  3. Context flag; for the entry handler its value is 0.

The function's return code is not used.

Example

The following sample function logs the current statement in a text file.

/* This function is installed as a prototyped function.*/
/* It writes the current time, name of the current */
/* engine, and the command which Panther will execute */
/* to a file called dbi.log. */
/* dbms ONENTRY CALL dbientry  */
#include <smdefs.h>

int
dbientry (stmt, engine, flag)
char *stmt;
char *engine;
int flag;
{
FILE *fp;
time_t timeval;

fp = fopen ("dbi.log", "a");
timeval = time(NULL)
fprintf (fp, "%s\n%s\n%s\n\n",
ctime(&timeval), engine, stmt);
fclose (fp);
return 0;
}

This sample function displays a message before performing any database operations.

// dbms ONENTRY JPL entrymsg

proc entrymsg
msg setbkstat "Processing. Please be patient..."
flush
return 0

See Also

ONEXIT, Chapter 12, "DBMS Global Variables," Chapter 37, "Processing Application Errors," in Application Development Guide