5 Replies Latest reply: Apr 29, 2014 9:21 PM by malg RSS

    Accessing VARBINARY (blob data): ORA-31046: TT2610: Operand data type 'VARBINARY'

    malg

      I am working on a prototype application (Pro*C++, Pro*C) for our evaluation of Timesten.

      By making heavy use of conditional compilation, I am able to generate 2 different versions of one of our application programs from a single set of source code files.

       

      Version1(ora): keeping application functionality, using oracle for access to all tables

      Version2(ora+tt): uses oracle connections for access to all tables except for 1 table cached in in TT. Uses TT connection for access to 1 table cached as AWT global cache group in TT.

       

      The overall business logic etc. can thus remain undisturbed in the majority of the source code.

      The conditional compilation is used to handle connections (ora/tt), the use of connection host variable “at :tt_db” in EXEC SQL statements, and additional DECLARE .. STATEMENT prior to prepared statements etc. that are required for TimesTen.

       

      I am however running into trouble with access to the column holding BLOB data in my cached table.

      The column is defined as  VARBINARY (4194304) in  TimesTen, and defined as BLOB in table in Oracle. The host variable for the column-data is defined as a OCIBlobLocator.

       

      In order to make the host variable datatype compatible with VARBINARY column datatype I added a TO_BLOB() call to the select statement for the column in my TT-application.

      (Reference: “The TO_BLOB function converts VARBINARY or BINARY to a BLOB”, http://docs.oracle.com/cd/E11882_01/timesten.112/e21642/function.htm#CACHJAJE)

       

      Example:

       

      OCIBlobLocator *blob;

      short wInd;

      char row[MY_ROWID_BUFLEN];

      strcpy( row, forRowId );   // forRowId holds the result of a “fetch rowid” from the table.

       

      EXEC SQL ALLOCATE :blob;

      EXEC SQL at :tt_db SELECT TO_BLOB(E_BLOB) INTO :blob:wInd FROM E_TABLE WHERE ROWID = :row;

       

      I was hoping that the function TO_LOB() would providd the necessasary conversion and the remaining logic for handling blobs could remain the same in my source code, including the host-variable defined as an OCIBlobLocator. However, the selection statement above statement gives the following error:

      ORA-31046: TT2610: Operand data type 'VARBINARY' invalid for operator

       

      What is the best way to solve this problem?

       

      Thanks

      M