c++sqloracle-databaseocci

Getting a VARCHAR2 type column: ORA-01460: unimplemented or unreasonable conversion requested


I have a column of type and size VARCHAR2<50> in my db table. I am using getBlob() method in my CPP code to get the value. I face exception as followed.

Exception:

ORA-01460: unimplemented or unreasonable conversion requested

@ line Blob blob = rset->getBlob(1);

Code:

    if(rset->next())
            {
                Blob blob = rset->getBlob(1);
                if(blob.isNull())
                    cout << "Null Blob" << endl;
                else
                {
                    blob.open (OCCI_LOB_READONLY);
                    int blobLength=blob.length();
                    Stream *instream = blob.getStream (1,0);
                    char *buffer = new char[blobLength];
                    memset (buffer, NULL, blobLength);
                    instream->readBuffer (buffer, blobLength);
                    for (int i = 0; i < size; ++i)
                    cout << (int) buffer[i];
                    cout << endl;
                    delete (buffer);
                    blob.closeStream (instream);
                }
                blob.close ();      
    }

Please let me know your comments. Thanks.

PS: I have checked the forum and got the post with the same exception but could not find relevant to what I face.


Solution

  • Modify the query to use utl_raw.cast_to_raw(col1) instead of simply returning the column.

    Although I wonder if you would be better off using plain old VARCHAR2 instead of trying to process it like a BLOB.