Before starting to write this article I was wondering if it was of any use to anyone. Who in their right state of mind would use the Database Gateway for xxx, be it Sybase or Adabase or whatever othere database was to be used. If you have to, simply configure another data source in your code and read data from where you need it. Note that I said read! Ever since Piet de Visser’s presentation about simplicity I have been a great supporter of the simplicity approach. Or, like James Morle likes to quote, simplicity is the ultimate form of sophistication.
Transparent Gateways desupported
So, anyway, I have been asked to link Sybase ASE 15.0.3 to an Oracle 10.2.0.4 database, all on Solaris 10/SPARC 64bit. A quick proof of concept had to be performed. Initially I started out with Transparent Gateway for Sybase, the name of the product for 10g Release 2. I should have known something was wrong when the link to download the software was broken and I had to manually copy & paste it. Well to cut a long story short, 10.2 gateways are desupported since 2008! I wasted a whole 2 hours before that came up on MOS. The workaround is to use > 10.2 software for this, and I went for 11.2. MOS states that this is possible for > 220.127.116.11, > 10.1.0.4 and > 10.2.0.3. My database was 10.2.0.4 which means I’m fine.
Database Gateway for Sybase
As always the new software is on OTN, under the 11.2 database downloads. Click on “See all” to access and download solaris.sparc64_11gR2_gateways.zip. I downloaded and unzipped the file to /u01/app/oracle/stage. The idea was to install the gateway into its own Oracle home, as all the installed software was 10.2.0.4 and lower. Again, as always it’s required to unset all Oracle related environment variables such as ORACLE_SID, AGENT_HOME, OMS_HOME, LD_LIBRARY_PATH_64, LD_LIBRARY_PATH, ORACLE_HOME etc.
The installation is really straight forward as you’d expect. Ensure that you have X11 forwarding enabled and an X server available (I use XMing), and execute “runInstaller”.
- Choose an appropriate name for the home location and path. Mine were OraGtw11g_home1 and /u01/app/oracle/product/gateway/18.104.22.168 but any path (not pointing to an existing ORACLE_HOME) is fine
- On the “Available Product Components” page select “Oracle Database Gateway for Sybase”
- On the configuration screen enter the hostname where your Sybase database is running, the port number (from $SYBASE/interfaces) and the database name to be accessed. Don’t worry, all these parameters can be changed later
- Start the installation
- When prompted, perform a typical install using netca.
- Exit the Universal Installer
Great, that’s all done now! Some more configuration steps are to be performed still.
Configuring the Gateway Home
I’d recommend that you enter the gateway ORACLE_HOME into /var/opt/oracle/oratab (or /etc/oratab, if you are not on Solaris). This way navigating is greatly simplified.
The connection information Oracle needs to connect to Sybase is stored in a configuration file located in the following location:
This is populated with the values provided during the installation, but for troubleshooting purposes you should set the logging to ON:
Once connections to Sybase have been established, reset the value to OFF to avoid excessive log file generation. The log files are generated in $ORACLE_HOME/dg4sybs/log, one for each query making use of the connection to Sybase.
By default, all stored procedures do not return a result set to the use. To change this behaviour, set the following parameter to TRUE:
The next step is to configure the listener. You should have performed a typical configuration during the installation (i.e. netca will have run). If so, edit $ORACLE_HOME/network/admin/listener.ora and add a static SID into the SID_LIST as in the following example:
# listener.ora Network Configuration File: # /u01/app/oracle/product/gateway/22.214.171.124/network/admin/listener.ora # Generated by Oracle configuration tools. SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (PROGRAM = dg4sybs) (ENV = /u01/app/oracle/product/gateway/126.96.36.199/dg4sybs/driver/lib:/u01/app/oracle/product/gateway/188.8.131.52/lib) (SID_NAME = dg4sybs) (ORACLE_HOME = /u01/app/oracle/product/gateway/184.108.40.206) ) )
LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) )
Unlike earlier versions of the gateway, the Sybase OCS libs don’t need to be included in the ENV variable. Obviously, if there is a listener on your host already, add the entries to the existing Now start the listern
Configuring the Database
Before Oracle can access the Sybase system, it must have an entry in its tnsnames.ora file to contact the listener we just created/modified:
dg4sybs = (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)) (CONNECT_DATA= (SID=dg4sybs)) (HS=OK) )
The hostname needs to refer to where the gateway’s listener runs on, as will the port. The SID needs to match the gateway SID defined in the SID_LIST_LISTENER parameter of the gateway’s listener.ora.
Within Oracle, create a database link to the Sybase database:
SQL> create database link dg4sysb connect to user identified by password using 'dg4sysbs';
Enclose the username and password in double-quotes as they are case sensitive. That’s it, you can now query the Sybase database from within Oracle.
With this setup it is now possible to query Sybase tables, and stored procedures. I have written a very basic one to demonstrate that it’s possible. Logging on to Sybase, I created a simple stored procedure to report the version, similar to the v$version view in Oracle.
1> drop procedure myversion 2> go 1> set chained on 2> go 1> create procedure myversion ( @ver varchar(255) OUTPUT ) as select @ver = @@version 2> go
Now on Oracle, I can query this like this:
set serveroutput on declare v varchar2(4000); begin "dbo"."myversion"@DG4SYSB(v); dbms_output.put_line(v); end; /
And this worked!