Create a notification procedure.
RETCODE dbnpcreate(dbproc) DBPROCESS *dbproc;
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.
SUCCEED or FAIL.
dbnpcreate creates a notification procedure. 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.
The notification procedure name and its parameters must have been previously defined using dbnpdefine and dbregparam.
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.
Like other registered procedures, notification procedures are useful for inter-application communication and synchronization, because applications can request to be advised when a notification procedure executes.
Notification procedures may be created only in Open Server. At this time, Adaptive Server Enterprise does not support notification procedures.
A DB-Library/C application requests to be notified of a registered procedure’s execution using dbregwatch. The application may request to be notified either synchronously or asynchronously.
This is an example of creating a notification procedure:
DBPROCESS *dbproc;
DBINT status;
/*
** Let’s create a notification procedure called
** “message” which has two parameters:
** msg varchar(255)
** user idint
*/
/*
** Define the name of the notification procedure
** "message"
*/
dbnpdefine (dbproc, "message", DBNULLTERM);
/*
** The notification procedure has two parameters:
** msg varchar(255)
** user idint
** 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");
}