background image
<< GMO database | Switching from the Access database to the text database >>

DB_FetchNext function

<< GMO database | Switching from the Access database to the text database >>
Getting Started: A Tutorial
139
8 T
ESTING
D
ATABASES
Running the Sample Testcase
The following table lists and describes the functions that were performed.
Function
Description
DB_Connect
Opens a connection to the GMO database and returns
a database handle, stored in the 4Test variable hdbc.
Note that you must pass in a connection string that
specifies the data source name you named on the User
DSN tab of the ODBC Data Source Administrator, in
this case, gmovb.
DB_ExecuteSql
Submits the database handle, as returned by the DB_
Connect function, and a string specifying a SQL
statement. Here a SELECT statement retrieves all
customer records from the cidb table and places them
in alphabetical order by last name (last_name). The
function returns a handle to the executed SELECT
statement.
DB_FetchNext
(or
DB_
FetchPrevious
)
Must be used after DB_ExecuteSQL to retrieve the
next (or previous) row of results of the SQL statement.
The first argument is the handle to the executed SQL
statement. Following the handle is a list of 4Test
output variables representing the table columns in
order. DB_FetchNext fills the output variables starting
with the first column and continuing in order through
the row until the function runs out of variables.
For example, custnum, the first output variable, holds
the row value of the first column (customer_number);
the second variable, fname, holds the row value of the
second column (first_name), and so on. The point is
that values cannot be skipped; even though we're
interested in only the second and third values (last and
first names), the testcase must retrieve the first value
too. Note that the output variables -- custnum, lname
and fname -- must be declared as strings, the same
type as the table columns. (Alternately, output can be
specified as a single list variable or even a record
variable, which may or may not have fields for all the
columns.) The DB_FetchNext function terminates
(returns
FALSE
) when there are no more rows to
retrieve.