In my project, our client widely use Oracle database for their data. I hope Oracle is widely used database. So here I will explain making connection from SAS to Oracle database, my routine activity. Also, you will find the common issues and how to rectify them.
Exploring tnsnames.ora
To make connection to Oracle database, we should make an
entry in tnsnames.ora. The tnsnames.ora file will be inside Oracle DB client
installation drive. By default installation directory and tnsnames.ora file will
be in /base-directory/oracle/product/11.2.0/client_1/network/admin/tnsnames.ora
Base-directory = Can be any directory.
What will be inside tnsnames.ora file?
The tnsnames.ora file is a configuration file for Oracle
client which holds information about the server. To make it simple, your
machine needs to contact another machine and this entry holds the address of
another machine. So what does the address will look like? The below image is the
sample tns entry.
TNS entry with schema name CHSLKJE |
In above image, only the service-name, ip address and port
number varies for each entry. The service name is also known as schema or SID
of Oracle database.
How to check whether the entry is correct?
Oracle client has a utility called tnsping. Using tnsping you can ping the database. The output will
be success if the entry is right or it will show error messages like Timed Out
etc.
You need to set environment variable to run this command.
Without environment variable you will get the error - tnsping: command not found.
Comment below if you need to know the environment variable of you system.
Other methods:
You can run LIBNAME statement for Oracle database in SAS
Enterprise Guide to check the entry. If the library get assigned then the entry
is correct.
Comments
Post a Comment