sp_regwatch

Description

Add the client to the notification list for a registered procedure.

Syntax

sp_regwatch proc_name [options]

Parameters

proc_name

The name of the registered procedure the client wishes notification for.

options

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.

Table 4-4: Values for sp_regwatch options parameter

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

Examples

Example 1

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.

Example 2

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.

Usage

Messages

See also

sp_regcreate, sp_regnowatch, sp_regdrop