SQLGetData - cSQLStatement
Get data of a column in chunks (variable length data)
Type: Function
Return Data Type: String
Parameters
| Parameter | Type | Description |
|---|---|---|
| iCol | Integer | Column to get data from |
| iLen | Integer | Length of data to get |
Syntax
Function SQLGetData Integer iCol Integer iLen Returns String
Call Example
Get SQLGetData iCol iLen to StringVariable
Description
In DataFlex 20.0 and higher, SQLGetData cannot be used to get binary data, as binary data can no longer be stored in string variables. SQLGetData is a legacy method and cannot handle characters split across 2 chunks of data. Use SQLGetDataToUChar instead to correctly retrieve such data.
Get the value of a column. SQLGetData is intended to get column data in chunks. If a statement selects a large object column, BLOB, CLOB, it is impossible to get the data of that column in one call. Normally the exact size of the column is not known upfront and it can grow to very big proportions (4 GB in some backends). In such cases, you can use SQLGetData to get the column value piece by piece.
The function will fill the global integer status variable SQLResult when the last chunk of data is retrieved. It will return the chunk of data that was retrieved.
If the column is less than 16 KB, use SQLColumnValue.
Sample
This code sample shows how to use SQLGetData to get a column's data in chunks of 1 KB.
Handle hoSQLMngr
Handle hdbc hstmt
Integer iFetchResult
String sChunk
Object oSQLHandler Is A cSQLHandleManager
Move Self to hoSQLMngr
End_Object
Get SQLFileConnect of hoSQLMngr Customer.File_number to hdbc
Get SQLOpen of hdbc to hstmt
Send SQLExecDirect of hstmt "SELECT photograph from employee"
Repeat
Get SQLFetch of hstmt to iFetchResult
If (iFetchResult <> 0) Begin
Repeat
Get SQLGetData of hstmt 1 1024 to sChunk
Send HandlePictureChunk to hoPicturehandler sChunk
Until (SQLResult <> SQLSuccess)
End
Until (iFetchResult = 0)
Send SQLClose of hstmt
Send SQLDisconnect of hdbc
If you are executing a SELECT statement that returns multiple columns, the text or varchar columns must be last in the SELECT statement or you may get an "invalid desriptor index" error.
Return Value
Returns data from a column.