Fixing ORA-28500 With DG4ODBC: Strange Bracket Symbol When Connecting to Non-Oracle Databases


When connecting from an Oracle database to a non-Oracle system (like PostgreSQL or SQL Server) using DG4ODBC and UnixODBC, you might hit a confusing and hard-to-interpret error:


 Symptom: ORA-28500 With Just a Bracket [

You issue a query like this:


SQL> select * from "t"@pglink;

And receive:


select * from "t"@pglink * ERROR at line 1: ORA-28500: connection from ORACLE to a non-Oracle system returned this message: [

That lone square bracket ([) in the error output doesn’t offer much help.


Log Insight

Check the gateway trace file under:


/u01/db/hs/log/pgdsn_agt_15012.trc

You’ll likely find a line like:


Exiting hgocont, rc=28500 at 2021/12/23-14:57:07 with error ptr
FILE:hgocont.c LINE:2842 ID:Something other than invalid authorization

🧭 Root Cause

This issue occurs because your Oracle database is using a Unicode character set (AL32UTF8), but the gateway session doesn't define a compatible environment to handle that encoding.

Check it with:


SELECT * FROM NLS_DATABASE_PARAMETERS WHERE
PARAMETER = 'NLS_CHARACTERSET';

Output:


NLS_CHARACTERSET = AL32UTF8

In this setup, the Oracle Gateway doesn’t know how to represent Unicode characters for the non-Oracle ODBC driver, leading to a malformed error — displayed as just [.


Solution: Define HS_LANGUAGE in init File

You need to explicitly set a compatible character set that bridges the Oracle side and the ODBC driver.

Edit the Gateway Initialization File

Example file path:
/u01/db/hs/admin/initpgdsn.ora

Add or modify the following line:


HS_LANGUAGE=AMERICAN_AMERICA.WE8ISO8859P1

This tells the gateway to use a Western European encoding that avoids Unicode conflicts with many ODBC drivers.


Example: Final Working initpgdsn.ora


# initpgdsn.ora - DG4ODBC gateway configuration for pgdsn HS_FDS_CONNECT_INFO = pgdsn HS_FDS_TRACE_LEVEL = DEBUG HS_FDS_SHAREABLE_NAME = /usr/lib64/libodbc.so # Fix ORA-28500 bracket issue with Unicode databases HS_LANGUAGE=AMERICAN_AMERICA.WE8ISO8859P1 # ODBC config environment set ODBCINI=/etc/odbc.ini

Apply and Restart Listener

After saving the file:


lsnrctl stop lsnrctl start

 Retest the Query


select * from "t"@pglink;

This time, the query should run successfully without ORA-28500 or the mysterious [






Please do like and subscribe to my youtube channel: https://www.youtube.com/@foalabs If you like this post please follow,share and comment