Long data and SQLPutData ?
am 08.08.2007 00:40:37 von Lothar BehrensHi,
I need some advice how to update a BLOB column. Reading it with
SQLGetData seems to be easier :-)
Do I need the commented code to 'shift' the bigger memory block into
the bound buffer while calling
SQLParamData and SQLPutData ?
I do set multiple column data before I do a SQLSetPos. So I have bound
columns therefore.
Do I get trouble, when I update some BLOB columns in between ?
Are there other issues with that code ?
Thanks, Lothar
Here I have code developed yet:
lbErrCodes LB_STDCALL lbQuery::setBinaryData(int column,
lb_I_BinaryData* value) {
// Declare a binary buffer to send 5000 bytes of data at a time.
SQLCHAR BinaryPtr[5000];
SQLINTEGER longDataLen;
SQLRETURN rc, retcode;
// The size may be more than 5000
longDataLen = SQL_LEN_DATA_AT_EXEC(value->getSize());
rc = SQLBindCol(hstmt, column, SQL_C_BINARY, (void *)BinaryPtr, 0,
&longDataLen);
retcode = SQLSetPos(hstmt, 1, SQL_UPDATE, SQL_LOCK_NO_CHANGE);
if (retcode == SQL_NEED_DATA)
{
retcode = SQLParamData(hstmt, (void **) &BinaryPtr);
while(retcode == SQL_NEED_DATA)
{
/*
//This code should be here to 'shift' the
datapieces.
void* peace = value->getNextDataPiece(5000);
long len = value->getCurrentPieceSize();
memcpy(BinaryPtr, piece, len);
*/
retcode = SQLPutData(hstmt, BinaryPtr, SQL_NTS);
/* check for error here */
retcode = SQLParamData(hstmt, (void **) &BinaryPtr);
}
}
return ERR_NONE;
}
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?
http://archives.postgresql.org