Install perl DBD::Oracle module without installing Oracle server onCentOS

I am in the situation of using ora2pg to migrate an Oracle database to postgreSQL. To install ora2pg, DBD::Oracle is required. To install DBD:Oracle, the environmental variable $ORACLE_HOME is required. However, it is not easy to set up an environmental variable for $ORACLE_HOME since I am using a remote dedicated Oracle server. To overcome the problem, I downloaded and installed the following three rpm packages: Please be advised that it should be no problem to set $ORACLE_HOME on a machine which happens to be the Oracle server.
# download link for Linux 64bit
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
oracle-instantclient11.2-basic-11.2.0.3.0-1
oracle-instantclient11.2-devel-11.2.0.3.0-1
oracle-instantclient11.2-sqlplus-11.2.0.3.0-1
I then added the $ORACLE_HOME to ~/.bashrc file.
#By default, the installation path is /usr/lib/oracle/11.2/client64/
export ORACLE_HOME="/usr/lib/oracle/11.2/client64/"
If you want connect to the Oracle database from command line using sqlplus, you could add $ORACLE_HOME/bin to you PATH, though the syntax for connecting to a remote database using its SID is nasty.
PATH=$PATH:/usr/lib/oracle/11.2/client64/bin
sqlplus AERS/AERS@'(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=remote_server_address)(PORT=1521)))(CONNECT_DATA=(SID=sid_code)))'
Now, you have done all the steps for running sqlplus on a command line. Will you enjoy the using? You probably not at this moment. Since running sqlplus without further tweaking is a pain in Linux command line: you do not have your history(using upper arrow) or you can not use left/right arrow to edit your sql command. Here is a solution, using rlwrap
# install required repository
wget http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6-8.noarch.rpm
# install rlwrap if it does not exit in your system
sudo yum install rlwrap
#then run
rlwrap sqlplus ***
You could also add he following alias in your ~/.bashrc file
vim ~/.bashrc
#add the following into the file
alias sqlplus='rlwrap sqlplus'

2 comments:

  1. When someone writes an article he/she keeps the thought of a user in his/her brain that how a user
    can understand it. Thus that's why this paragraph is perfect. Thanks!

    ReplyDelete
  2. […] Recently, I moved all my development environment to Ubuntu. I encounter some problems when I was installing Oracle SQL Plus following my previous post at http://b2ctran.wordpress.com/2013/05/31/372/. […]

    ReplyDelete

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...