Oracle® Objects for OLE C++ Class Library Developer's Guide 10g Release 2 (10.2) Part Number B14308-01 |
|
Applies To
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). */