|
Syntax
INT = dbGet(hstmt as INT)
Description
Gets the next record from a result set.
Parameters
hstmt - Statement handle returned by dbExecSQL or dbPrepareSQL.
Return value
TRUE if the record was retrieved and any bound variables filled in with column data. FALSE if the end of the result set was reached or there were no records in the result set.
Remarks
A column that is nullable and currently set to NULL can be determined by dbIsNull after a dbGet operation. A NULL value can also be determined by checking the optional 'pReturn' variable used when binding the column with dbBindVariable.
See Also: dbGetNext, dbGetPrev, dbExecSQL, dbPrepareSQL
Example usage
hstmt = dbExecSQL(pdb,"SELECT * FROM Addresses")
error = dbGetErrorCode(hstmt)
IF LEN(error)
PRINT
PRINT "Error Code: ", error
PRINT "Error Text: ", dbGetErrorText(hstmt)
PRINT
ENDIF
IF hStmt
'bind the columns in the table to appropriate variables
'column numbers start at 1 starting from the left.
dbBindVariable(hstmt,1,Address_ID)
dbBindVariable(hstmt,2,first)
dbBindVariable(hstmt,3,last)
dbBindVariable(hstmt,4,street)
dbBindVariable(hstmt,5,city)
dbBindVariable(hstmt,6,state)
dbBindVariable(hstmt,7,zip)
'dbGet returns TRUE if data has been retrieved and stored
'in the bound variables. Or FALSE if the end of data has been reached or an error occured
WHILE dbGet(hstmt)
PRINT "ID:",Address_ID
PRINT first," ",last
PRINT street
IF dbIsNull(hStmt,5) = FALSE
PRINT city, "," ,state, " ", zip
ENDIF
PRINT
ENDWHILE
dbFreeSQL(hstmt)
ENDIF
|