LOB file reference variables in ODBC applications
As an alternative to using LOB locators, if an application requires the entire LOB column value, it can request direct file input and output for LOBs. Database queries, updates, and inserts can involve the transfer of single LOB column values into and from files.
The two Db2 ODBC LOB file
access functions are:
SQLBindFileToCol()
- Binds (associates) a LOB column in a result set with a file name.
Example:
SQLUINTEGER fileOption = SQL_FILE_OVERWRITE; SQLINTEGER fileInd = 0; SQLSMALLINT fileNameLength = 14; /* ... */ SQLCHAR fileName[14] = "LOBFile"; /* ... */ rc = SQLBindFileToCol(hstmt, 1, fileName, &fileNameLength, &fileOption, 14, NULL, &fileInd);
SQLBindFileToParam()
- Binds (associates) a LOB parameter marker with a file name. Example:
SQLUINTEGER fileOption = SQL_FILE_OVERWRITE; SQLINTEGER fileInd = 0; SQLSMALLINT fileNameLength = 14; /* ... */ SQLCHAR fileName[14] = "LOBFile"; /* ... */ rc = SQLBindFileToParam(hstmt, 3, SQL_BLOB, fileName, &fileNameLength, &fileOption, 14, &fileInd);
The file name is the absolute path name of the file. On execute or fetch, data transfer to and from the file occurs, in a similar way to that of bound application variables. A file options argument that is associated with these two functions indicates how the files are to be handled at the time of transfer.