Execute a registered procedure.
RETCODE dbregexec(dbproc, options) DBPROCESS *dbproc; DBUSMALLINT options;
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 2-byte bitmask, either DBNOTIFYALL or DBNOTIFYNEXT.
If options is DBNOTIFYALL, Open Server will notify all DBPROCESSes watching for the execution of this registered procedure.
If options is DBNOTIFYNEXT, Open Server will notify only the DBPROCESS that has been watching the longest.
SUCCEED or FAIL.
dbregexec completes the process of executing a registered procedure. Because a notification procedure is simply a special type of registered procedure, a notification procedure may also be executed using dbregexec.
The procedure name and its parameters must have been previously defined using dbreginit and dbregparam.
To execute a registered procedure, a DB-Library/C application must:
Initiate the call using dbreginit.
Describe the procedure’s parameters, if any, using dbregparam.
Execute the procedure using dbregexec.
An application cannot execute a registered procedure that is not defined in Open Server. dbreglist returns a list of registered procedures that are currently defined.
Registered procedures are useful for inter-application communication and synchronization, because applications can request to be advised when a registered procedure executes.
Registered procedures may be created only in Open Server. At this time, Adaptive Server Enterprise does not support registered procedures. An application can use dbnpcreate, dbregparam, and dbnpcreate to create a registered procedure.
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 executing a registered procedure:
DBPROCESS *dbproc;
DBINT newprice = 55;
DBINT status;
/*
** Initiate execution of the registered procedure
** "price_change"
*/
dbreginit (dbproc, "price_change", DBNULLTERM);
/*
** The registered procedure has two parameters:
** name varchar(255)
** newprice int
** So pass these parameters to the registered
** procedure.
*/
dbregparam (dbproc, "name", SYBVARCHAR, NULL,
"sybase");
dbregparam (dbproc, "newprice", SYBINT4, 4,
&newprice);
/* Execute the registered procedure: */
status = dbregexec (dbproc, DBNOTIFYALL);
if (status == FAIL)
{
fprintf(stderr, "ERROR: Failed to execute \
price_change!\n");
}
else if (status == DBNOPROC)
{
fprintf(stderr, "ERROR: Price_change does \
not exist!\n");
}
else
{
fprintf(stdout, "Success in executing \
price_change!\n");
}