Skip to content

SQLGetData Command

Obsolete

Refer to the SQLGetData method in the cSQLStatement class.

SQLGetData hstmt iColumnNumber [Length iLen] To Var

The SQLGetData command allows a programmer to retrieve data from an individual column by its number. This command can be used to traverse a results set when the number of columns is unknown at the time of program creation. It can also be utilized when a column is too large to retrieve in one go. In such cases, the SQLGetData command can be employed to obtain the column data in chunks.

Example Usage

Open Customer
SQLFileConnect Customer To hdbc
SQLOpen hdbc To hstmt
SQLExecDirect hstmt "SELECT * FROM Customer"
SQLStmtAttribute hstmt SQLSTMTATTRIB_COLUMNCOUNT To iNumColumns

If (iNumColumns) Begin
    SQLFetch hstmt
    While SQLResult
        For iCount From 1 To iNumColumns
            SQLGetData hstmt iCount To sColValue
            Show sColValue
        Loop
        Showln
        SQLFetch hstmt
    End
End
Else ;
    Showln "NO columns in result!"

Open Customer
SQLFileConnect Customer To hdbc
SQLOpen hdbc To hstmt
SQLExecDirect hstmt "SELECT Picture FROM Customer"

Repeat
    SQLFetch hstmt
    Move SQLResult To FetchResult
    If (FetchResult) Begin
        Repeat
            SQLGetData hstmt 1 Length 1024 To sPictureChunk
            If (SQLResult) ;
                Send HandlePictureChunk sPictureChunk
        Until (SQLResult <> SQLSuccess)
    End
Until (Not(FetchResult))