dbGetData

Top  Previous  Next

Syntax

INT = dbGetData(hstmt as INT,column as INT,variable as ANYTYPE,opt cbSize as INT)

Description

Gets data directly from a column after a dbGet, dbGetNext or dbGetPrev operation.

Parameters

hstmt - Statement handle returned by dbExecSQL or dbPrepareSQL.

column - Ones based column number to retrieve data from.

variable - Variable to store retrieved data into.

cbSize - Optional. For string and raw binary data you must specify the maximum length. Defaults to 255.

Return value

TRUE if data was successfully retrieved and stored in the variable. FALSE on error or empty result set.

Remarks

dbGetData is an alternative to binding variables and is not supported by all database drivers.  Certain drivers will not allow directly retrieving data from a column if it is already bound to a variable. The Access driver supports both binding and direct retrieval. Binding variables will always result in faster retrieval of data.

dbGetData supports most of the Emergence BASIC built in types and raw binary data.

See Also: dbGetTime, dbGetDate, dbGetTimeStamp

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
    WHILE dbGet(hstmt)
        dbGetData(hstmt,1,Address_ID)
        dbGetData(hstmt,2,first)
        dbGetData(hstmt,3,last)
        dbGetData(hstmt,4,street)
        dbGetData(hstmt,5,city)
        dbGetData(hstmt,6,state)
        dbGetData(hstmt,7,zip)
        PRINT "ID:",Address_ID
        PRINT first," ",last
        PRINT street
        IF dbIsNull(hStmt,5) = FALSE
            PRINT city, "," ,state, " ", zip
        ENDIF
        PRINT
    ENDWHILE
ENDIF