INT _handle ; handle to database
INT _retCode ; return code
TEXT _name ; product name
TEXT _type ; product type
; parametrized SQL command
TEXT _sql = "SELECT Name, Type FROM Products WHERE ID>= #PAR# AND ID<= #PAR#"
SQL_CONNECT MyDatabase, _handle, _retCode
SQL_PREPARE _handle, _retCode, _sql BINDOUT _name, _type
SQL_BINDIN _handle, _retCode, 1, 100 ; read all products between 1 and 100
DO_LOOP
SQL_FETCH _handle, _retCode
EXIT_LOOP _retCode # _ERR_NO_ERROR
; data processing goes here
END_LOOP
SQL_FREE _handle
SQL_DISCONNECT _handle