Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2002
    Posts
    6

    Unanswered: Error while trying to use BLOBs (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

    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.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: Error while trying to use BLOBs (or Long VarChar for BIT Data) in DB2

    Originally posted by Mike Ryksen

    [IBM][CLI Driver][DB2/NT] SQL0352N An unsupported SQLTYPE was encountered in position "1" of
    the input list (SQLDA). SQLSTATE=56084

    ...

    The INSERT statement looks like this:

    INSERT into MT02_Media(MediaUID,CRC,MediaSize,mediaBlob)
    VALUES(1,100200,1000,?)

    You don't provide specifics about what language you use to access the database but it looks like you're trying to supply a variable of incompatible type. You may want to read the DB2 app. dev. guide to determine valid type mappings between the DB2 SQL and the language you use.

  3. #3
    Join Date
    Feb 2002
    Posts
    6
    I am using Delphi 5 and ODBCExpress (which is a wrapper around the ODBC driver).

    The sample code I am using is as follows:

    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;

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Originally posted by Mike Ryksen
    I am using Delphi 5 and ODBCExpress (which is a wrapper around the ODBC driver).

    Sorry, I don't think I can help you here - I don't know anything about Delphi. Its documentation should list correct mappings between its data types and SQL types.

  5. #5
    Join Date
    Jan 2003
    Posts
    35
    I executed the following queries & they worked fine. Kindly see if there are any differences
    CREATE TABLE MT02_Media(
    MediaUID INTEGER NOT NULL,
    CRC VARCHAR(50),
    MediaSize INTEGER,
    MediaBlob LONG VARCHAR FOR BIT DATA,
    CONSTRAINT PK2 PRIMARY KEY (MediaUID)
    ) ;

    INSERT into MT02_Media(MediaUID,CRC,MediaSize,mediaBlob)
    VALUES(1,'100200',1000,'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;'
    );

  6. #6
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •