Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> insert BLOB into Oracle DB via ODBC: inconsistent datatypes
Hi,
I am having big troubles when trying to insert an unsigned char array
(image thumbnail) into a BLOB field of an Oracle 10g table. Her is
what I am doing:
char* stat = "INSERT INTO TEMP (SHOT_ID,FRAME) VALUES (?,?)";
rc = SQLPrepare(hstmt, (SQLCHAR*)(const_cast<char*>(stat)), SQL_NTS);
[...]
SQLINTEGER type;
SQLPOINTER pToken;
rc = SQLBindParameter(hstmt , 2, SQL_PARAM_INPUT,
SQL_C_BINARY,SQL_LONGVARBINARY,0,0,
(SQLPOINTER)2,0,&type);
type = SQL_LEN_DATA_AT_EXEC(0);
rc = SQLExecute(hstmt);
while (SQL_NEED_DATA == rc) {
rc = SQLParamData(hstmt, &pToken); if (rc == SQL_NEED_DATA) { unsigned char* data = .... //fetch image data and store into data array... SQLINTEGER data_size = .... //get size of thumbnail in byte rc = SQLPutData(hstmt, data, data_size); }
rc = SQLParamData(hstmt, &pToken);
if (rc != SQL_SUCCESS) { //print error string: //SQLGetDiagRec returns "inconsistent datatypes: expected NUMBER got BLOB" }
I am completely in the dark and have no clue where might be the problem....Any help is very welcome!! Thanks a lot in advance! chris Received on Fri Nov 16 2007 - 10:51:41 CST