Skip Headers

Oracle® Objects for OLE C++ Class Library Developer's Guide
10g Release 1 (10.1)

Part Number B10119-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Feedback

GetCount Method

Applies To

OConnectionCollection

ODatabaseCollection

OFieldCollection

OParameterCollection

OSessionCollection

Description

This method returns the number of items in the collection.

Usage

long GetCount(void) const

Remarks

The various Collection classes inherit the GetCount method from their parent OOracleCollection. The GetCount method returns the number of items in the collection. The collection is dynamic; the number of items in the collection reflects the current conditions, not the conditions when the Collection object was created.

A closed collection will return 0 items.

Return Value

The number of items in the collection.

Example

This example looks at the number of connections in the current session.

// construct and open an OSession on the default session

OSession defsess(0);

// get the connection collection

OConnectionCollection connc = defsess.GetConnections();

// how many connections are there now?

int nconn = connc.GetCount();

// now add a connection by creating a new database object

ODatabase odb("ExampleDB", "scott/tiger", 0);

// how many connections are there now?

int nconn2 = connc.GetCount();

// nconn2 will equal nconn + 1 because of the new connection

/*

Actually, nconn2 == nconn + 1 only if a previous connection was

not shared. Connection sharing would have occurred if there was

a previous connection, within the same session, that used the

same connection information (database name, user name, password).

*/