A registered procedure is a procedure that is defined and installed in a running Open Server. Registered procedures require Open Server version 2.0 or later. At this time, registered procedures are not supported by Adaptive Server Enterprise.
For DB-Library/C applications, registered procedures provide a way for inter-application communication and synchronization. This is because DB-Library/C applications connected to an Open Server can “watch” for a registered procedure to execute. When the registered procedure executes, applications watching for it receive a notification that includes the procedure’s name and the arguments it was called with.
DB-Library/C applications may create only a special type of registered procedure, known as a “notification procedure.” A notification procedure differs from a normal Open Server registered procedure in that it contains no executable statements.
For example, suppose the following:
stockprice is a real-time DB-Library/C application monitoring stock prices.
price_change is a notification procedure created in Open Server by the stockprice application. price_change takes as parameters a stock name and a price differential.
sellstock, an application that puts stock up for sale, has requested to be notified when price_change executes.
When stockprice, the monitoring application, becomes aware that the price of Extravagant Auto Parts stock has risen $1.10, it executes price_change with the parameters “Extravagant Auto Parts” and “+1.10”.
When price_change executes, Open Server sends sellstock a notification containing the name of the procedure (price_change) and the arguments passed to it (“Extravagant Auto Parts” and “+1.10”). sellstock uses the information contained in the notification to decide to put 100 shares of Extravagant Auto Parts stock up for sale.
price_change is the means through which the stockprice and sellstock applications communicate.
Registered procedures as a means of communication have the following advantages:
A single call to execute a registered procedure can result in many client applications being notified that the procedure has executed. The application executing the procedure does not need to know how many, or which, clients have requested notifications.
The registered procedure communication mechanism is server-based. Open Server acts as a central repository for connection addresses. Because of this, client applications can communicate without having to connect directly to each other. Instead, each client simply connects to the server.
A DB-Library/C application can:
Create a registered procedure in Open Server
Drop a registered procedure
List all registered procedures defined in Open Server
Request to be notified when a particular registered procedure is executed
Drop a request to be notified when a particular registered procedure is executed
List all registered procedure notifications
Execute a registered procedure
Install a user-supplied handler to be called when an application receives notification that a registered procedure has executed
Poll Open Server to see if any registered procedure notifications are pending
The following are registered procedure routines:
dbnpcreate – creates a notification procedure.
dbnpdefine – defines a notification procedure.
dbregdrop – drops a registered procedure.
dbreglist – returns a list of all registered procedures currently defined in Open Server.
dbreghandle – installs a handler routine for a registered procedure notification.
dbreginit – initiates execution of a registered procedure.
dbregnowatch – cancels a request to be notified when a registered procedure executes.
dbregparam – defines a parameter for a registered procedure.
dbregexec – executes a registered procedure.
dbregwatch – requests to be notified when a registered procedure executes.
dbregwatchlist – returns a list of registered procedures that a DBPROCESS is watching for.
dbpoll – in an application that uses registered procedure notifications, this routine is used to check whether any notifications have arrived.