Adobe ColdFusion 8

getData

Description

Retrieves a data element from a row and column of a query. Row and column indexes begin with 1. You can find the number of rows in a query by calling getRowCount. You can find the number of columns in a query by calling getColumns.

Returns the value of the requested data element.

Category

Query interface

Syntax

public String getData(int iRow, int iCol)

Throws

IndexOutOfBoundsException if an invalid index is passed to the method.

See also

setData, addRow

Parameters

Parameter

Description

iRow

Row to retrieve data from (1-based)

iCol

Column to retrieve data from (1-based)

Example

The following example iterates over the rows of a query and writes the data back to the user in a simple, space-delimited format:

int iRow, iCol ;
int nNumCols = query.getColumns().length ;
int nNumRows = query.getRowCount() ;
for ( iRow = 1; iRow <= nNumRows; iRow++ )
{
    for ( iCol = 1; iCol <= nNumCols; iCol++ )
    {
        response.write( query.getData( iRow, iCol ) + " " ) ;
    }
    response.write( "<BR>" ) ;
}