Re: can not write a BLOB
Posted in 2003
Hi Glen, In JDBC, which is what it looks like you're using, you need to (1) use the PreparedStatement class; and (2) cast the String as an Object when you do your "set". I 've never done this in ESQL-C but I would imagine there is some analogous way there too. String someString = "someVeryLongStringThatOnlyWillFitIntoABlob"; try { PreparedStatement prepStmt = conn.PrepareStatement ( " insert into tableWithBlobCol ( blobCol ) values ( ? ) "); prepStmt.setObject ( 1, (Object) someString ); prepStmt.executeUpdate(); } catch ( SQLException SQLe) { } --John 202-502-2599 (or x 2599) "Glen Johnson" <glen@csisoft.com> Sent by: owner-informix-list@iiug.org 09/10/2003 09:26 AM Please respond to "Glen Johnson" To: informix-list@iiug.org cc: Subject: can not write a BLOB I have a Windows OLE DB COM application written in Microsoft C++ that processes MSSQL tables containing BLOB columns. I need to port this code for use over an Informix database. I have installed the Informix Client and registered the Informix OLE DB provider. The existing code can read Informix tables with BLOB columns with the column type set to DBTYPE_IUNKNOWN, but it cannot insert or update a table with a similar BLOB column. I have tried modifying the code to (1) write the BLOB data using the provider-provided storage object and (2) specify a consumer-provided storage object. The former appears to do nothing to the rowset and the latter generates a unsupported conversion (0x80040E1D) error when the code calls (IRowset::)SetData(). Any help or coding examples would be appreciated. class CBlobAccessor { public: LONG m_objectid; ISequentialStream* m_edoc; BEGIN_COLUMN_MAP(CBlobAccessor) COLUMN_ENTRY(1, m_objectid) BLOB_ENTRY(2, IID_ISequentialStream, STGM_READ, m_edoc) END_COLUMN_MAP() BEGIN_PARAM_MAP(CBlobAccessor) COLUMN_ENTRY(1, m_objectid) END_PARAM_MAP() DEFINE_COMMAND(CBlobAccessor, _T("SELECT object_id, edoc FROM edocument WHERE object_id = ?")) sending to informix-list