Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: insert BLOB into Oracle DB via ODBC: inconsistent datatypes
On Nov 16, 11:51 am, "exilberli..._at_googlemail.com"
<exilberli..._at_googlemail.com> wrote:
> 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
I cannot comment on the code but whose and what version of an ODBC or OLE driver are you using? What tool set is this code written in? What version of the Oracle client is installed? What Oracle version is the target database?
For example the MSDAORA, MS OLE to Oracle, often used with SQL Server 2000 to create linked databases to Oracle does not support the Oracle LOB datatype according to a MS document I have. It is too old.
HTH -- Mark D Powell -- Received on Fri Nov 16 2007 - 13:38:10 CST
![]() |
![]() |