Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> insert BLOB into Oracle DB via ODBC: inconsistent datatypes

insert BLOB into Oracle DB via ODBC: inconsistent datatypes

From: <exilberliner_at_googlemail.com>
Date: Fri, 16 Nov 2007 08:51:41 -0800 (PST)
Message-ID: <b9ef1146-441b-4fa3-9b6a-d0c3742c1469@b32g2000hsa.googlegroups.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US