I am currently trying to insert an image (the image is streamed) into DB2 using the IBM DB2 ODBC driver, and I am getting the following error.
[IBM][CLI Driver][DB2/NT] SQL0352N An unsupported SQLTYPE was encountered in position "1" of
the input list (SQLDA). SQLSTATE=56084
I am using Delphi 5 and ODBCExpress and here is the sample code:
TOracle,TDB2: begin
mDestQ2.Statement.BlobPlacement := bpByParts;
mDestQ2.Statement.BlobSize := MS.Size;
mDestQ2.Statement.Prepare;
GetMem(RawData,MS.Size);
try
MS.Seek(0,0);
mDestQ2.Statement.BindParamCore(1, SQL_C_BINARY, RawData, SQL_LONGVARBINARY);
mDestQ2.Statement.ParamSize[1] := MS.Size;
MS.Read(RawData^,MS.Size);
mDestQ2.Statement.Execute;
finally
FreeMem(RawData,MS.Size);
end;
end;
TMSSQL: begin
mDestQ2.Statement.Prepare;
mDestQ2.Statement.BindBinary(1,MS);
mDestQ2.Statement.Execute;
end;
The server is DB2 Version 7.2 FixPak 8, and I am binding the streamed blob to a parameter in the INSERT statement. It works perfectly for Oracle and MS SQL Server but, I am struggling to get it to work for DB2.
The INSERT statement looks like this:
INSERT into MT02_Media(MediaUID,CRC,MediaSize,mediaBlob)
VALUES(1,’100200’,1000,?)
And the structure of the table is:
CREATE TABLE MT02_Media(
MediaUID INTEGER NOT NULL,
CRC VARCHAR(50),
MediaSize INTEGER,
MediaBlob LONG VARCHAR FOR BIT DATA,
CONSTRAINT PK2 PRIMARY KEY (MediaUID)
)
;
As I said, I tried changing the field type to BLOB but I received the same error.
Has anyone experienced this before or know what I am doing wrong?
Thanks in advance for any help.