i want to use vc++ to insert blob data to db2,but db2 and odbc does not support to do that . i find internet and ibm web,the mothed is :use CLI to do it.
the link is:
http://www-3.ibm.com/software/data/d...lifunction.htm

content is:
Using DB2 CLI function in scripts
The code in this section assumes the following table definition:

CREATE TABLE blobs (id INT, data BLOB(8192))

It may be desired to insert and retrieve table column values in scripts which you attach to forms or controls. Below are two routines which show how this can be done for BLOB data types using DB2 CLI function. Once a pointer to BLOB is retrieved, the Palm API WinDrawBitmap can be used to display the BLOB value.






// **************************************************
// Function to insert data into a BLOB data type
// **************************************************
SQLRETURN DB2e_insert_blob(Word id, Word size, char *blob)
{
// SQL parameters 1 2 3
static SQLCHAR SQL_insert[] = "insert into blobs values (?,?,?)";
SQLINTEGER SQL_size = size;



SQLRETURN rc;



// Prepare the insert.
if (rc = SQLPrepare(stmt, SQL_insert, SQL_NTS))
return myerror("SQLPrepare (insert)"), rc;



// Bind the blob id.
if (rc = SQLBindParameter(stmt, 1,
SQL_PARAM_INPUT, SQL_C_SHORT, SQL_INTEGER, 0, 0,
&id, 0, NULL))
return myerror("SQLBindParameter (insert/1)"), rc;



// Bind the blob size.
if (rc = SQLBindParameter(stmt, 2,
SQL_PARAM_INPUT, SQL_C_SHORT, SQL_INTEGER, 0, 0,
&size, 0, NULL))
return myerror("SQLBindParameter (insert/2)"), rc;



// Bind the blob data.
if (rc = SQLBindParameter(stmt, 3,
SQL_PARAM_INPUT, SQL_C_BINARY, SQL_BLOB, size, 0,
blob, size, &SQL_size))
return myerror("SQLBindParameter (insert/3)"), rc;



// Now perform the insert.
if (rc = SQLExecute(stmt))
return myerror("SQLExecute (insert)"), rc;



return SQL_SUCCESS;
}



// **************************************************
// Function to get pointer to BLOB
// **************************************************
char *DB2e_get_blob(Word id)
{
// SQL paramaters 1
static SQLCHAR SQL_select[] = "select size,
blob from blobs where id = ?";



Word size;
char *blob;
SQLINTEGER SQL_size;



// Prepare the select.
if (SQLPrepare(stmt, SQL_select, SQL_NTS))
return myerror("SQLPrepare (select)"), (char *)NULL;



// Bind the blob id.
if (SQLBindParameter(stmt, 1,
SQL_PARAM_INPUT, SQL_C_SHORT, SQL_INTEGER, 0, 0,
&id, 0, NULL))
return myerror("SQLBindParameter (select/1)"),
(char *)NULL;



// Now perform the select.
if (SQLExecute(stmt))
return myerror("SQLExecute (select)"), (char *)NULL;



// Try to fetch the blob.
switch (SQLFetch(stmt)) {
case SQL_SUCCESS:
break;
case SQL_NO_DATA_FOUND:
return (char *)NULL;
default:
return myerror("SQLFetch"), (char *)NULL;
}



// Read the size column.
if (SQLGetData(stmt, 1,
SQL_C_SHORT,
&size, 0,
NULL))
return myerror("SQLGetData (size)"), (char *)NULL;



if (!(blob = MemPtrNew(size)))
return (char *)NULL;



// Read the blob column.
if (SQLGetData(stmt, 2,
SQL_C_BINARY,
blob, size,
&SQL_size))
return myerror("SQLGetData (data)"), (char *)NULL;



if (size != SQL_size)
return ErrDisplay("DB2e: Retrieved corrupted blob"),
(char *)NULL;



return blob;
}