Define a notification procedure.
RETCODE dbnpdefine(dbproc, procedure_name, namelen) DBPROCESS *dbproc; DBCHAR *procedure_name; DBSMALLINT namelen;
A pointer to the DBPROCESS structure that provides the connection for a particular front-end/server process. It contains all the information that DB-Library/C uses to manage communications and data between the front end and the server.
A pointer to the name of the notification procedure being defined.
The length of procedure_name, in bytes. If procedure_name is null-terminated, pass namelen as DBNULLTERM.
SUCCEED or FAIL.
dbnpdefine defines a notification procedure. Defining a notification procedure is the first step in creating it.
A notification procedure is a special type of Open Server registered procedure. A notification procedure differs from a normal Open Server registered procedure in that it contains no executable statements. Notification procedures are the only type of Open Server registered procedure that a DB-Library/C application can create.
To create a notification procedure, a DB-Library/C application must:
Define the procedure using dbnpdefine
Describe the procedure’s parameters, if any, using dbregparam
Create the procedure using dbnpcreate
All DB-Library/C routines that apply to registered procedures apply to notification procedures as well. For example, dbregexec executes a registered procedure, which may or may not be a notification procedure. Likewise, dbreglist lists all registered procedures currently defined in Open Server, some of which may be notification procedures.
This is an example of defining a notification procedure:
DBPROCESS *dbproc;
DBINT status;
/*
** Let’s create a notification procedure called
** "message" which has two parameters:
** msg varchar(255)
** userid int
*/
/*
** Define the name of the notification procedure
** "message"
*/
dbnpdefine (dbproc, "message", DBNULLTERM);
/* The notification procedure has two parameters:
** msg varchar(255)
** userid int
** So, define these parameters. Note that
** neither of the parameters is defined with a
** default value.
*/
dbregparam (dbproc, "msg", SYBVARCHAR,
DBNODEFAULT, NULL);
dbregparam (dbproc, "userid", SYBINT4,
DBNODEFAULT, 4);
/* Create the notification procedure: */
status = dbnpcreate (dbproc);
if (status == FAIL)
{
fprintf(stderr, "ERROR: Failed to create \
message!\n");
}
else
{
fprintf(stdout, "Success in creating \
message!\n");
}