I’m using Informix and the .NET SDK (C#):
Basically, is there any way to insert a blob when doing a standard insert sql statement?
INSERT INTO mytable (name, theblob) VALUES ('foo', ? what goes here ?);
Oh, and the data I have is in a form of a byte[] array.
A couple of notes:
1) You should use parameterized queries
A couple of things to note: Informix has a bug when it comes to the Client SDK 3.5.xC7 (so far). You can easily pass in the byte array during inserts, but you will have a 609 error when doing updates if you pass in a byte[] array. Instead, you must use the
IfxBlobobject.You have to pass in an IfxBlob instead during update, so you might as well also do it during inserts.
Also, keep in mind that if you are trying to set
null, you will get an error. Instead, if the value is null pass in DBNull.Value.DO NOT SPECIFY THE TYPE OF PARAMETER
If you do either of those, you’ll have to do the following:
"INSERT INTO mytable (name, theblob) VALUES (?, ?::blob);";"INSERT INTO mytable (name, theblob) VALUES (?, ?::byte);";You can see that it will be a pain in the butt to have different queries because of the type and value. Just don’t specify a DbType or IfxType and let the Informix .NET provider map the correct types for you (even though it can’t map the byte[] array properly on an Update).
Hope that works out for you, because I went through the same pains trying to figure this out and discovering what I think is a bug in the Informix .NET provider (Ver: 3.5.xC7).