Re: PSQLODBC - Selecting bytea columns in Oracle - Mailing list pgsql-odbc

From Tsunakawa, Takayuki
Subject Re: PSQLODBC - Selecting bytea columns in Oracle
Date
Msg-id 0A3221C70F24FB45833433255569204D1F5B4BC5@G01JPEXMBYT05
Whole thread Raw
In response to PSQLODBC - Selecting bytea columns in Oracle  (<john.robinson@vaisala.com>)
Responses Re: PSQLODBC - Selecting bytea columns in Oracle
List pgsql-odbc

Hello, John,

 

You tried retrieving one row with one column of type bytea with the following query, didn't you?

 

SELECT A1."icon" FROM "oracle_dbgw_test" A1

 

According to the line 3512 in your log, The driver seems to have gotten 7402 bytes from the database server.  So the driver has the data.

 

qresult: len=7402, buffer='\xffd8ffe000104a46494600010100000100010000ffdb0043000d090a0b0a080d0b0a0b0e0e0d0f13201513121213271c1e17202e2931302e292d2c333a4a3e333646372c2d405741464c4e525352323e5a615a50604a51524fffdb0043010e0e0e131113261515264f352d354f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4f4fffc00011080050007803012200021101031101ffc4001f0000010501010101010100000000000000000102030405060708090a0bffc400b5100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9faffc4001f0100030101010101010101010000000000000102030405060708090a0bffc400b51100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a2627282

...

 

 

On the other hand, the following line shows that buffer is null, meaning that the caller (Oracle Gateway in your case) didn't specify the buffer to receive the data.

 

fetch: cols=1, lf=0, opts = 0xa035d70, opts->bindings = 0xa034bb0, buffer[] = (nil)

 

 

I'm not sure whether this is related, but the following manual page mentions "BLOB and CLOB data cannot be read by pass-through queries".  Why don't you ask the Oracle support what this means?

 

http://docs.oracle.com/database/121/ODBCU/feature.htm#ODBCU763

 

FYI, I could successfully get the content of a bytea column using isql command of unixODBC as follows.  Before this, I did "CREATE TABLE a (c bytea); INSERT INTO a VALUES('abcde');".

 

[isql session]

SQL> select * from a;

+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

 

| c                                                                                                                                                                                                                                                              |

+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

| 6162636465                                                                                                                                                                                                                                                     |

+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

 

 

For psqlODBC developers: Doesn't column_size = -4 indicate any problem?

 

PARSE: fieldtype=17, col_name='icon', column_size=-4

 

Regards

Takayuki Tsunakawa

 

 

From: pgsql-odbc-owner@postgresql.org [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of john.robinson@vaisala.com
Sent: Monday, July 11, 2016 11:20 PM
To: pgsql-odbc@postgresql.org
Subject: [ODBC] PSQLODBC - Selecting bytea columns in Oracle

 

Hi,

 

I hope you can help.  We have a PostgreSQL database which stores image data in bytea columns.  I am attempting to read these images from within an Oracle database using the Oracle Database Gateway for ODBC and the PSQLODBC driver with the iODBC driver manager.  However, the bytea column is being truncated to a single byte when selected within Oracle.  I have attached the mylog_oracle????.log file plus the odbc.ini and odbcinst.ini.  The software versions we are using are:

 

PostgreSQL database -  9.2.17

Oracle Database - 11.2.0.4

PSQLODBC driver – 9.5.3

iODBC Driver manager – 3.52.10

 

I have been working with Oracle Support for a while on this issue.  Initially Oracle was displaying the bytea columns as a raw datatype with a length of 255 bytes.  Oracle recommended setting the ByteaAsLongVarBinary to 1 in the odbc.ini file.  This resulted in the bytea columns to be truncated to 1 byte within Oracle.  Oracle have seen the log files and claim the data is being truncated within the ODBC driver.

 

Is there anything else I can try to resolve this issue so I can read all the data within the bytea columns from Oracle?  Please let me know if I can provide any further information.

 

Many Thanks,

 

Regards,

 

John Robinson

 

John Robinson | Oracle Database Administrator
Vaisala Ltd, Information Services, Elm House, 351 Bristol Road, Birmingham, B5 7SW, United Kingdom
Tel  +44 121 683 1237| Mobile +44 7739 874462
Email 
John.Robinson@vaisala.com |  www.vaisala.com
Follow us on: Twitter | Facebook | YouTube | LinkedIn

P  Please consider our environment before printing this email

 

pgsql-odbc by date:

Previous
From: "Tsunakawa, Takayuki"
Date:
Subject: Re: psqlODBC 09.05.0300 (x86) - problem with SQL_QUERY_TIMEOUT
Next
From: Dave Cramer
Date:
Subject: broken link on web