ocilib::Subscription Class Reference

Subscription to database or objects changes. More...

`#include <ocilib.hpp>`

Inherits ocilib::HandleHolder< OCI_Subscription *>.

## Public Types

enum | ChangeTypesValues { ObjectChanges = OCI_CNT_OBJECTS, RowChanges = OCI_CNT_ROWS, DatabaseChanges = OCI_CNT_DATABASES, AllChanges = OCI_CNT_ALL }
| Subscription changes flags values. More...
typedef void(* | NotifyHandlerProc) (Event &evt)
| User callback for subscriptions event notifications.
typedef Flags< ChangeTypesValues > | ChangeTypes
| Subscription changes flags. More...

## Public Member Functions

| Subscription ()
| Default constructor.
void | Register (const Connection &connection, const ostring &name, ChangeTypes changeTypes, NotifyHandlerProc handler, unsigned int port=0, unsigned int timeout=0)
| Register a notification against the given database. More...
void | Unregister ()
| Unregister a previously registered notification. More...
void | Watch (const ostring &sql)
| Add a SQL query to monitor.
ostring | GetName () const
| Return the name of the given registered subscription.
unsigned int | GetTimeout () const
| Return the timeout of the given registered subscription.
unsigned int | GetPort () const
| Return the port used by the notification.
Connection | GetConnection () const
| Return the connection associated with a subscription handle. More...

## Detailed Description

Subscription to database or objects changes.

This class wraps the OCILIB object handle OCI_Subscription and its related methods

Warning
  Environment::Events flag must be passed to Environment::Initialize() to be able to use subscriptions

Definition at line 6959 of file ocilib.hpp.

## Member Typedef Documentation

## ChangeTypes

typedef Flags<ChangeTypesValues> ocilib::Subscription::ChangeTypes

Subscription changes flags.

Possible values are Subscription::ChangeTypesValues

Definition at line 6998 of file ocilib.hpp.

## Member Enumeration Documentation

## ChangeTypesValues

enum ocilib::Subscription::ChangeTypesValues

Subscription changes flags values.

Enumerator
ObjectChanges | Request for changes at objects (e.g. tables) level (DDL / DML)
RowChanges | Request for changes at rows level (DML)
DatabaseChanges | Request for changes at database level (startup, shutdown)
AllChanges | Request for all changes

Definition at line 6979 of file ocilib.hpp.

## Member Function Documentation

## Register()

void ocilib::Subscription::Register | ( | const Connection & | connection,
|  | const ostring & | name,
|  | ChangeTypes | changeTypes,
|  | NotifyHandlerProc | handler,
|  | unsigned int | port = `0`,
|  | unsigned int | timeout = `0`
| ) |  |

inline

Register a notification against the given database.

Parameters

  connection | - Connection handle
  name | - Notification name
  changeTypes | - Subscription type
  handler | - User handler callback
  port | - Port to use for notifications
  timeout | - notification timeout

Note
  Requires Oracle Client 10gR2 or above

Definition at line 6478 of file ocilib_impl.hpp.

References ocilib::Check(), OCI_SubscriptionRegister(), and OCI_SubscriptionUnregister().

## Unregister()

void ocilib::Subscription::Unregister | ( |  | ) |

inline

Unregister a previously registered notification.

Note
  Environment::Cleanup() will automatically unregister any non unregistered subscriptions
  If the database connection passed to Register() has been closed by the time that the application calls Unregister(), the library internally reconnects to the given database, performs the deregistration and then disconnects

Definition at line 6487 of file ocilib_impl.hpp.

## GetConnection()

Connection ocilib::Subscription::GetConnection | ( |  | ) | const

inline

Return the connection associated with a subscription handle.

Note
  It may return a null connection object if the connection used at Register() time has been closed

Definition at line 6518 of file ocilib_impl.hpp.

References ocilib::Check(), and OCI_SubscriptionGetConnection().