dblink_ora provides an OCI-based database link that allows you to run SELECT, INSERT, UPDATE or DELETE statements on the data stored in an Oracle system from within a PolarDB-O. OCI is short for Oracle Call Interface.

If you want to enable Oracle connectivity, download Oracle's freely available OCI drivers.

Connect to an Oracle database

If the Oracle Instant Client that you download does not include the libclntsh.so library, you must create a symbolic link named libclntsh.so that points to the downloaded version. Navigate to the Instant Client directory and run the following command:

ln -s libclntsh.so.version libclntsh.so

where, version is the version number of the libclntsh.so library. For example:

ln -s libclntsh.so.12.1 libclntsh.so

Before you create a link to an Oracle server, you must tell the PolarDB-O where to find the OCI driver.

Set the LD_LIBRARY_PATH environment variable on Linux or PATH on Windows to the lib directory of the Oracle client installation directory.

For Windows only, you can also set the value of the oracle_home configuration parameter in the postgresql.conf file. The value specified in the oracle_home configuration parameter overrides the Windows PATH environment variable.

The LD_LIBRARY_PATH environment variable on Linux and the PATH environment variable or oracle_home configuration parameter on Windows must be set properly each time you start the PolarDB-O.

When you use a Linux service script to start the PolarDB-O, make sure that LD_LIBRARY_PATH is set within the service script so it is in effect when the script invokes the pg_ctl utility to start the PolarDB-O.

For Windows only, if you want to set the oracle_home configuration parameter in the postgresql.conf file, edit the file by adding the following line:

oracle_home = 'lib_directory '

Substitute the name of the Windows directory that contains oci.dll for lib_directory.

After you set the oracle_home configuration parameter, you must restart the server for the changes to take effect. You can restart the server from the Windows Services console.