If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Error while trying to insert into BLOB field (or Long VarChar for BIT Data) in DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-24-03, 16:25
Mike Ryksen Mike Ryksen is offline
Registered User
 
Join Date: Feb 2002
Posts: 6
Error while trying to insert into BLOB field (or Long VarChar for BIT Data) in DB2

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.
Reply With Quote
  #2 (permalink)  
Old 07-02-03, 09:51
Mike Ryksen Mike Ryksen is offline
Registered User
 
Join Date: Feb 2002
Posts: 6
I just want to let everyone know that I found the problem. I was using the DB2 ODBC driver version 8.1 locally and the server is DB2 version 7.1... once I switched my local driver to 7 then it worked fine.

So I am not totally sure if it is a problem with the version 8 of the DB2 ODBC driver or the combination of the two versions that caused the problem.
Reply With Quote
  #3 (permalink)  
Old 08-29-03, 16:44
tmhatre tmhatre is offline
Registered User
 
Join Date: Aug 2003
Posts: 2
Question how do you know the driver version?

Quote:
Originally posted by Mike Ryksen
I just want to let everyone know that I found the problem. I was using the DB2 ODBC driver version 8.1 locally and the server is DB2 version 7.1... once I switched my local driver to 7 then it worked fine.

So I am not totally sure if it is a problem with the version 8 of the DB2 ODBC driver or the combination of the two versions that caused the problem.

Question: I am facing the same problem. How does one know what version the driver is for? I have SQLDB2V5.dll and SQLDB232.dll on my mchine and both files show version 5.2.0.2. Now how does one know whether these drivers are for version 7 or for version 8?
Reply With Quote
  #4 (permalink)  
Old 08-29-03, 16:48
Mike Ryksen Mike Ryksen is offline
Registered User
 
Join Date: Feb 2002
Posts: 6
Go to your ODBC Data Source Adminstrator and click on the Drivers tab. Scroll down until you find the DB2 driver and the version will be listed.
Reply With Quote
  #5 (permalink)  
Old 08-29-03, 17:31
tmhatre tmhatre is offline
Registered User
 
Join Date: Aug 2003
Posts: 2
how do you know the driver version?

Quote:
Originally posted by Mike Ryksen
Go to your ODBC Data Source Adminstrator and click on the Drivers tab. Scroll down until you find the DB2 driver and the version will be listed.
I looked at the BDE Administrator, ODBC drivers, DB2, and checked out the file version which says 5.2.0.2. What it does not tell me is whether this driver is for version DB2 ver 7 or DB2 version 8? How did you find that out? Also from where can I get the driver for DB2 ver 7, if the one I have is for DB 2 ver 8?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On