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

GetFieldIndex Method

Applies To

ODynaset

Description

This method returns the index of the field indicated by fieldname.

Usage

int GetFieldIndex(const char *fieldname) const

Arguments

fieldname The name of the field as it appears in the SQL statement that the dynaset used most recently.

Remarks

Accessing fields of a dynaset by index is more efficient than accessing them by name. Therefore, if you need to access a particular field many times, use this method to translate its name into its index.

Return Value

The 0-based index of the field; -1 on error.

Example

This example looks at the salaries of many employees.

// open up the employee database

ODatabase empdb("ExampleDB", "scott", "tiger");

// get the main employee table

ODynaset emps(empdb, "select * from emp");

// now look at all their salaries

// let's get the index of the salary field for speed

int salind = emps.GetFieldIndex("sal");

double salary; // variable we'll use to get the salary

while (!emps.IsEOF())

{

emps.GetFieldValue(salind, &salary);

// do some processing

emps.MoveNext();

}


 
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