Database.ResultSet

Description

A class for retrieving the result of a database SQL query.

A Database.ResultSet is returned by Database.Connection.query(), and by Database.PreparedStatement.execute(). The class provides methods and properties for retrieving the result data associated with a SQL query execution.

Database.Connection con = Database.Connection("DBConnector1");
con.connect();
Database.ResultSet result = con.query("SELECT * FROM customers");
while (result.fetchNext()) {
	string firstName = result["FirstName"];
	string lastName = result["LastName"];
	for (int j = 1; j <= result.numFields; j++) {
		Variant column1Value = result[j];
		...
	}
	...
}
con.disconnect();
	

A Database.ResultSet implements a forward-only cursor. This means you can only traverse through the results once. This can either be done manually, using fetchNext(), or automatically by dumping the data to a table with cloneTo(). However, you cannot do both. In other words, you cannot clone the result using cloneTo(), and then also use fetchNext() to traverse the result again, or vice versa.

Properties

numFields The number of fields in the result set.

Methods

cloneTo Clones the result set to a destination table.
fetchNext Moves the cursor forward one record in the result.

Operators

[] Gets a result field value by its name or rank.

Details

Do no remove, this fixes the anchor on doc.flexsim.com

Database.ResultSet.numFields

readonly int numFields

Description

The number of fields in the result set.

Do no remove, this fixes the anchor on doc.flexsim.com

Database.ResultSet.cloneTo()

void cloneTo( Table destTable )

Description

Clones the result set to a destination table.

Database.Connection con = Database.Connection("DBConnector1");
con.connect();
con.query("SELECT * FROM customers").cloneTo(Table("Customers"));
con.disconnect();
Do no remove, this fixes the anchor on doc.flexsim.com

Database.ResultSet.fetchNext()

int fetchNext( )

Returns

int 1 if successful, 0 if the end of the result set has been reached.

Description

Moves the cursor forward one record in the result.

Do no remove, this fixes the anchor on doc.flexsim.com

Database.ResultSet.operator []

Variant operator []( int fieldRank )
Variant operator []( int fieldName )

Parameters

fieldRank The 1-based rank of the desired field
fieldName The name of the desired field

Returns

Variant The value of the given field for the result set's current record.

Description

Gets a result field value by its name or rank.