Add the client to the notification list for a registered procedure.
sp_regwatch proc_name [options]
The name of the registered procedure the client wishes notification for.
An CS_SMALLINT that specifies whether to notify the client just once or every time the procedure executes, and whether notification is synchronous or asynchronous. Table 4-4, below, shows the values that you can set for options. These values are bit flags, so you can set more than one at a time.
Values for option |
Function |
---|---|
CS_NOTIFY_NOWAIT |
Indicates asynchronous notification |
CS_NOTIFY_WAIT |
Indicates synchronous notification |
SRV_NOTIFY_ALWAYS |
Open Server will notify the client every time the procedure executes until the client disconnects or calls srv_regnowatch or dbregnowatch. This is the default. |
SRV_NOTIFY_ONCE |
Open Server removes the client from the notification list after it delivers a notification |
dbrpcinit(dbproc, "sp_regwatch", (DBUSMALLINT) 0);
dbrpcparam(dbproc, "@proc_name", 0, SYBCHAR,
15, 15, "pricechange");
dbrpcsend(dbproc);
This example adds the client to the notification list for a procedure called pricechange. Whenever the procedure executes, this client receives a notification.
optionval = SRV_NOTIFY_ONCE;
dbrpcinit(dbproc, sp_regwatch, (DBUSMALLINT)
DBWAIT);
dbrpcparam(dbproc, "@proc_name", 0, SYBCHAR,
15, 15, pricechange");
dbrpcparam(dbproc, "@options", 0, SYBINT4, -1,
-1, &optionval);
dbrpcsend(dbproc);
This example adds the client to the notification list for a procedure called pricechange. It receives notification that the procedure executed just once.
Open Server executes sp_regwatch internally when a client calls dbnpwatch.
If the procedure is dropped while a client is waiting for a notification, the client receives an error message indicating that the procedure is no longer registered.
Notification request added.
The notification request was added successfully.
proc_name is not a registered procedure.
The procedure specified with the proc_name parameter is not registered with Open Server.
Unable to add notification request.
Open Server was unable to add the request for some other reason.