Previous Next Contents Index


IHierResultSet interface (deprecated)

IHierResultSet is deprecated and is provided for backward compatibility only. New Java applications should use the standard servlet-JSP programming model.

For information about replacing IHierResultSet functionality in existing applications, see the Migration Guide.

The IHierResultSet interface represents a hierarchical result set retrieved by a hierarchical query. IHierResultSet provides methods to iterate through rows in the hierarchical result set and retrieve information about each row. Alternatively, an AppLogic can process hierarchical result sets by passing them directly to the Template Engine using evalOutput( ) in the AppLogic class (deprecated).

IHierResultSet is part of the Data Processing Engine (DPE) service. To create an instance of IHierResultSet, use execute( ) in the IHierQuery interface (deprecated), as shown in the following example:

IHierResultSet hrs

hrs = hqry.execute(0, 0, null);
Package
com.kivasoft

Methods
Method
Description
count( )
Returns the total number of rows retrieved so far from the data source for the specified child query.
getColumn( )
Returns the column definition for the column with the specified name in the specified child query.
getColumnByOrd( )
Returns the column definition for the column in the specified ordinal position for the specified child query.
getResultSet( )
Returns the result set for a specified child query.
getRowNumber( )
Returns the number of the current row for the specified child query in the hierarchical result set.
getValueDateString( )
Returns the value of a Date type column, as a string, from the specified child query in the result set.
getValueDouble( )
Returns the value of a double type column from the specified child query in the result set.
getValueInt( )
Returns the value of an int type column from the specified child query in the result set.
getValueString( )
Returns the value of a string type column from the specified child query in the result set.
moveNext( )
Moves to the next row for the specified child query in the result set.
moveTo( )
Moves to the specified row for the specified child query in the result set.

Example
The following code runs a hierarchical query and with the returned hierarchical result set, checks a user's access level to determine which listbox options to display:

// Create the hierarchical query

IHierQuery hqry = createHierQuery();
hqry.addQuery(qry, conn, "USERS", "", "");

// Execute the query
IHierResultSet hrs = hqry.execute(0, 0, null);

TemplateMapBasic map = new TemplateMapBasic();

// Determine whether result returned match
if(hrs.getRowNumber("USERS")==0)
return result("No user matches loginname: "+wantedUser);
String access=hrs.getValueString("USERS", "AccessLevel");
String selAdmin, selNormal;
if(access.compareTo("AccessAdmin")==0)
{
selAdmin="<option selected>"+"AccessAdmin"+"</option>\n";
selNormal="<option>Normal</option>\n";
}
else
{
selAdmin="<option>"+"AccessAdmin"+"</option>\n";
selNormal="<option selected>Normal</option>\n";
}
String select="<select name=accessControlLevel>\n"+selNormal+selAdmin+"</select>";

TemplateMapBasic tMap=new TemplateMapBasic();
tMap.put("ACCESS", select);

int ers = evalTemplate(template, (ITemplateData) hrs, tMap);
if (ers==0)
return result("");
else
return result("Failed to Generate HTML");
}
Related Topics
createHierQuery( ) in the AppLogic class (deprecated)

IHierQuery interface (deprecated)

count( )
Returns the total number of rows retrieved so far from the data source for the specified child query.

Syntax
public int count(
	String qryName)

qryName. Name of the child query that generated the result set.

Usage
Use count( ) to return the current number of rows processed so far in the result set. If iterating through rows in a result set that has been completely returned, use count( ) to determine the current maximum number of rows to process.

Tip
If result set buffering is enabled, the AppLogic can use count( ) to find the current number of rows in the buffer.

Rule
The specified child query must exist in the result set.

Return Value
An int value representing the number of rows in the result set retrieved so far, or zero for failure (such as an invalid child query name).

Example
// Create the hierarchical query

IHierQuery hqry = createHierQuery();
hqry.addQuery(qry, conn, "USERS", "", "");
// Execute the query
IHierResultSet hrs = hqry.execute(0, 0, null);
// Determine whether result returned match
if(hrs.count("USERS")==0)
return result("No user matches loginname: "+wantedUser);
String access=hrs.getValueString("USERS", "AccessLevel");
Related Topics
createHierQuery( ) in the AppLogic class (deprecated)

IHierQuery interface (deprecated)

getColumn( )
Returns the column definition for the column with the specified name in the specified child query.

Syntax
public IColumn getColumn(
	String qryName,
	String colName)

qryName. Name of the child query that generated the result set.

colName. Name of the column. Must not be qualified with the schema name or table name (if necessary, use column alias to ensure that the colName is unambiguous).

Usage
Use getColumn( ) when the data definition of the column is unknown and is required for subsequent operations. The AppLogic can then use methods in the IColumn interface (deprecated) to obtain descriptive information about a table column from the database catalog, such as the column name, precision, scale, size, table, and data type.

Rules
Tips
Return Value
IColumn object containing information from the retrieved column, or null for failure (such as an invalid child query name or column name).

Example
// Obtain column information for UserID field

IColumn col;
col = hrs.getColumn("USERS", "UserID")
. . . process column info using IColumn methods . . .
Related Topics
createHierQuery( ) in the AppLogic class (deprecated)

IHierQuery interface (deprecated)

IColumn interface (deprecated)

getColumnByOrd( )
Returns the column definition for the column in the specified ordinal position for the specified child query.

Syntax
public IColumn getColumnByOrd(
	String qryName,
	int colIndex)

qryName. Name of the child query that generated the result set.

colIndex. Ordinal position of a column in the result set. The ordinal position of the first column in the result set is 1, the second column is 2, and so on.

Usage
Use getColumnByOrd( ) when the data definition of the column is unknown and is required for subsequent operations. AppLogic can then use methods in the IColumn interface (deprecated) to obtain descriptive information about a table column from the database catalog, such as the column name, precision, scale, size, table, and data type.

Rules
Tip
Use getColumn( ) instead when the column name is known but its ordinal position is unknown.

Return Value
IColumn object containing information from the retrieved column, or null for failure (such as an invalid child query name or column name).

Example
// Obtain column information for UserID field

IColumn col1, col2, col3, col4;
col1 = hrs.getColumnByOrd("USERS", 1)
col2 = hrs.getColumnByOrd("USERS", 2)
col3 = hrs.getColumnByOrd("USERS", 3)
col4 = hrs.getColumnByOrd("USERS", 4)
. . . process column info using IColumn methods . . .
Related Topics
createHierQuery( ) in the AppLogic class (deprecated)

IHierQuery interface (deprecated)

IColumn interface (deprecated)

getResultSet( )
Returns the result set for a specified child query.

Syntax
public IResultSet getResultSet(
	String qryName)

qryName. Name of the child query that generated the result set to retrieve.

Usage
Use getResultSet( ) to retrieve and manipulate a particular child result set in the hierarchical result set. The AppLogic can then use methods in the IResultSet interface (deprecated) to get data from the result set columns.

Rule
The specified child query must exist in the result set.

Return Value
IResultSet object , or null for failure (such as an invalid child query name).

Example
// Look up list of customers matching criteria from database

IHierResultSet hrs = lookupCustomer(ssn, lastName, firstName, acctNum);

if (hrs == null)
{
return handleOBSystemError("Could not retrieve database results");
}
// Check the result set to see if any customers are found
IResultSet rs = hrs.getResultSet("SelCusts");

getRowNumber( )
Returns the number of the current row for the specified child query in the hierarchical result set.

Syntax
public int getRowNumber(
	String qryName)

qryName. Name of the child query that generated the result set.

Usage
When iterating through rows in a child set, use getRowNumber( ) to keep track of the number of rows processed.

Rule
The specified child query must exist in the result set.

Return Value
An int value representing the current row number in the child result set, or zero if the result set is empty or for failure (such as an invalid row or query name). The number of the first row in the result set is 1, the second row is 2, and so on. If zero is returned the first time AppLogic calls getRowNumber( ), that means the result set is empty for the specified child query.

Example
// Create the hierarchical query

IHierQuery hqry = createHierQuery();

hqry.addQuery(qry, conn, "USERS", "", "");

// Execute the query
IHierResultSet hrs = hqry.execute(0, 0, null);

TemplateMapBasic map = new TemplateMapBasic();
// Determine whether result returned match

if(hrs.getRowNumber("USERS")==0)
return result("No user matches loginname: "+wantedUser);
String access=rs.getValueString("USERS", "AccessLevel");
String selAdmin, selNormal;
if(access.compareTo("AccessAdmin")==0)
{
selAdmin="<option selected>"+"AccessAdmin"+"</option>\n";
selNormal="<option>Normal</option>\n";
}
else
{
selAdmin="<option>"+"AccessAdmin"+"</option>\n";
selNormal="<option selected>Normal</option>\n";
}
String select="<select name=accessControlLevel>\n"+selNormal+selAdmin+"</select>";
TemplateMapBasic tMap=new TemplateMapBasic();
tMap.put("ACCESS", select);
int ers = evalTemplate(template, (ITemplateData) rs, tMap);
if (ers==0)
return result("");
else
return result("Failed to Generate HTML");
}
Related Topics
createHierQuery( ) in the AppLogic class (deprecated)

IHierQuery interface (deprecated)

getValueDateString( )
Returns the value of a Date type column, as a string, from the specified child query in the result set.

Syntax
public String getValueDateString(
	String qryName,
	String colIName)

qryName. Name of the child query that generated the result set.

colName. Name of the column from which to retrieve the date.

Usage
Use getValueDateString( ) to retrieve date values from the result set for subsequent processing. The following is an example of the format in which getValueDateString( ) returns a date:

Jan 26 1998 12:35:00
Rule
The specified column must be a Date, Date Time, or Time data type.

Return Value
The date value as a string, or null for failure (such as an invalid column number or data type mismatch).

Related Topics
getValueDouble( )

getValueInt( )

getValueString( )

getValueDouble( )
Returns the value of a double type column from the specified child query in the result set.

Syntax
public double getValueDouble(
	String qryName,
	String colName)

qryname. Name of the child query that generated the result set.

colName. Name of the column from which to retrieve the double value.

Usage
Use getValueDouble( ) to retrieve decimal, floats, real, numeric, and double values from the result set for subsequent processing.

Rule
The specified column must be a double data type.

Return Value
A double value, or zero for failure (such as an invalid column number or data type mismatch).

Related Topics
getValueDateString( )

getValueInt( )

getValueString( )

getValueInt( )
Returns the value of an int type column from the specified child query in the result set.

Syntax
public int getValueInt(
	String qryName,
	String colName)

qryname. Name of the child query that generated the result set.

colName. Name of the column from which to retrieve the value.

Usage
Use getValueInt( ) to retrieve int or long values from the result set for subsequent processing.

Rule
The specified column must be an int or long data type.

Return Value
An int value, or zero for failure (such as an invalid column number or data type mismatch).

Related Topics
getValueDateString( )

getValueDouble( )

getValueString( )

getValueString( )
Returns the value of a string type column from the specified child query in the result set.

Syntax
public String getValueString(
	String qryName,
	String colName)

qryname. Name of the child query that generated the result set.

colName. Name of the column from which to retrieve the value.

Usage
Use getValueString( ) to retrieve string values from the result set for subsequent processing.

Rule
The specified column must be a String data type.

Return Value
A String value, or null for failure (such as an invalid column number or data type mismatch).

Related Topics
getValueDateString( )

getValueDouble( )

getValueInt( )

moveNext( )
Moves to the next row for the specified child query in the result set.

Syntax
public int moveNext(
	String qryName)

qryName. Name of the child query that generated the result set.

Usage
Use moveNext( ) when iterating through rows in the result set to retrieve the contents of the next sequential row.

Rule
The specified child query must exist in the result set.

Return Value
An int value for success (zero) or failure (non-zero, such as reaching the end of the result set). If the current row is the last row in the result set, calling moveNext( ) returns a non-zero int.

Related Topics
createHierQuery( ) in the AppLogic class (deprecated)

IHierQuery interface (deprecated)

moveTo( )
Moves to the specified row for the specified child query in the result set.

Syntax
public moveTo(
	String qryName,
	int nRow)

qryName. Name of the child query that generated the result set.

nRow. Number of the row in the result set to move to. The number of the first row in the result set is 1, the second row is 2, and so on.

Usage
Use moveTo( ) to move the internal cursor to a specific row in the result set, skipping over rows to be excluded from processing.

Rules
Tip
For certain database drivers, this operation may be very slow and should be avoided if possible.

Return Value
An int value for success (zero), or failure (non-zero, such as an invalid row number).

Related Topics
createHierQuery( ) in the AppLogic class (deprecated)

IHierQuery interface (deprecated)

 

© Copyright 1999 Netscape Communications Corp.