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. |
Do no remove, this fixes the anchor on doc.flexsim.com
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();