User Guide

774 Chapter 5: ColdFusion Java CFX Reference
// Print the list of columns to the user
response.write( "Columns in query: " ) ;
for( int i=0; i<nNumColumns; i++ )
{
response.write( columns[i] + " " ) ;
}
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
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>" ) ;
}
Parameter Description
iRow Row to retrieve data from (1-based)
iCol Column to retrieve data from (1-based)