SQLBindFile - cSQLStatement
Add a file to the list of files bound to the statement result.
Type: Procedure
Parameters
| Parameter | Type | Description |
|---|---|---|
| iFileNum | Integer | The number of the table to bind |
Syntax
Procedure SQLBindFile Integer iFileNum
Call Example
Send SQLBindFile iFileNum
Description
Binds a file buffer to a fetched row. This message is sent after the SQLFetch function to place the columns values in a file buffer. The buffer's status will not be updated by the SQLBindFile procedure. Whether the buffer's status is updated depends on the SQLFetchActivatesBuffer message calls.
It is not possible to bind a buffer of a different type than the Connectivity Kit in use. You cannot use SQLBindFile to bind a result set row of a SQL Server statement to a DataFlex file buffer. That means that if in the sample below SQLExecDirect is executed against SQL Server (through MSSQLDRV driver), the table Vendor (used in SQLBindFile) must be opened by the MSSQLDRV driver as well. Vendor cannot be opened by a different driver or as an embedded database (DataFlex) table. In that case, use the SQLColumnValue message.
If the file number that is passed is 0 (zero), the piBindFile property of the cSQLStatement object will be used for binding. If that property is not set, an error will be generated.
Sample
This code sample shows two ways to use SQLBindFile. One is by passing no file number; the other is by passing an explicit file number.
Handle hoSQLMngr
Handle hdbc hstmt
Integer iFetchResult
Object oSQLHandler Is A cSQLHandleManager
Move Self To hoSQLMngr
End_Object
Open Customer
Open Vendor
Get SQLFileConnect Of hoSQLMngr Customer.File_number To hdbc
//*** First sample
Showln ">> List Customers <<"
Get SQLOpen Of hdbc To hstmt
Send SQLExecDirect Of hstmt "select * from customer"
Repeat
Get SQLFetch Of hstmt To iFetchResult
If (iFetchResult <> 0) Begin
Send SQLBindFile Of hstmt 0
Showln Customer.Name ", " Customer.State
End
Until (iFetchResult = 0)
Send SQLClose Of hstmt
Showln
//*** Second sample
Showln ">> List Vendors <<"
Get SQLOpen Of hdbc To hstmt
Send SQLExecDirect Of hstmt "select * from vendor"
Repeat
Get SQLFetch Of hstmt To iFetchResult
If (iFetchResult <> 0) Begin
Send SQLBindFile Of hstmt Vendor.File_number
Showln Vendor.Name ", " Vendor.State
End
Until (iFetchResult = 0)
Send SQLClose Of hstmt
Send SQLDisconnect Of hdbc