Oracle Objects for OLE C++ Class Library
Release 9.2

Part Number A95896-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback

GetField Method

Applies To

ODynaset

OFieldCollection

Description

This method returns one of the associated field objects by way of an OField handle.

Usage

OField GetField(int index) const

OField GetField(const char *fieldname) const (for ODynaset only)

Arguments
Description
index
The 0-based index of the field. The index is the position of the field in the SQL query that created the current record set.
fieldname
The name of the field, as expressed in the SQL query.

Remarks

This method returns an OField object on the indicated field. The field object remains valid until the dynaset is refreshed or destroyed.

When getting a field from an OFieldCollection, the 0-based index still refers to a SQL query. Specifically, it refers to the SQL query of the dynaset that the OFieldCollection was gotten from.

Return Value

An OField, which will be open on success, closed on failure.

Example

This example demonstrates getting fields.

// open an ODatabase

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

// open an ODynaset

ODynaset dyn;

dyn.Open(odb, "select empno, ename, nvl(comm,0), hiredate date \

from emp");

// get a field by index

OField empnofield = dyn.GetField(0);

// get a field by name

OField namefield = dyn.GetField("ename");

// get a computed field by name

// we use the expression (which is the column name)

OField commfield = dyn.GetField("nvl(comm,0)");

// get a field that has been aliased - the column name is the alias

OField datefield = dyn.GetField("date");


 
Oracle
Copyright © 1998, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback