Search

OakieTags

Who's online

There are currently 0 users and 34 guests online.

Recent comments

Affiliations

rlwrap

How to use vi-style editing in SQL*Plus

This post is nothing new, and I created it after a little discussion on twitter about how to use readline support in SQL*Plus. The idea is not new, and I have compiled and used rlwrap for quite some time.

At the time, Frits Hoogland asked me why I didn’t use the EPEL package-and I had to admit to myself that I didn’t know the Extra Package for Enterprise Linux repository at all. But there is more to rlwrap and Linux I didn’t know, but first things first.

Installing rlwrap from EPEL

This is really simple-you can either add the EPEL repository to your /etc/yum.repos.d/ directory or simply download the rlwrap package and install it via RPM. A simple wget on your host does the trick. You can set environment variables when you’d like to use a proxy as shown here:

Compiling RLWRAP for Oracle Linux 6.1 x86-64

RLWrap is a great too to enhance the user experience with SQL*Plus by allowing it to make use of the GNU readline library. Search the Internet for RLWrap and sqlplus and you should get plenty of hits explaining how awesome that combination is.

Why am I writing this? I am currently in the process of upgrading my lab reference database server to Oracle Linux 6.1, and in the process I wanted to install the rlwrap tool to get read line support with SQLPlus. It’s actually quite simple, all I did after installing the operating system with the “database server” package is described in the few steps that follow this introduction.

First of all I was surprised that gcc wasn’t installed with the package group, and some other bits were missing too. This can easily be rectified by allowing access to the Oracle Public YUM server. I’m behind a gateway so have to use a proxy server:

[root@rhel61ref rlwrap-0.37]# export http_proxy=http://192.168.xx.10:3128
[root@rhel61ref rlwrap-0.37]# export https_proxy=https://192.168.xx.10:3128

This is a very basic SQUID setup without authentication. It’s also behind a firewall and cannot be accessed from the outside world.

Now with this set, go to /etc/yum.repos.d/ and use wget to get the repository configuration:

[root@rhel61ref rlwrap-0.37]# wget http://public-yum.oracle.com/public-yum-ol6.repo

This file needs to be edited-set “enabled” to 1 for the repository called [ol6_u1_base]. A quick “yum update” as root updates the repository information. I needed the following packages (including dependencies) to be installed as well:

[root@rhel61ref rlwrap-0.37]# yum install gcc
 [root@rhel61ref rlwrap-0.37]# yum install readline-devel

Now it’s time to get RLWrap itself, at the time of this writing it was version 0.37:

[root@rhel61ref rlwrap-0.37]# wget http://utopia.knoware.nl/~hlub/uck/rlwrap/rlwrap-0.37.tar.gz

I downloaded it to my home directory. There was a small problem related to the configure process:

[root@rhel61ref rlwrap-0.37]# ./configure
 checking build system type... Invalid configuration `x86_64-unknown-linux-': machine `x86_64-unknown-linux' not recognized
 configure: error: /bin/sh tools/config.sub x86_64-unknown-linux- failed
 [root@rhel61ref rlwrap-0.37]#

To work around this, you can use the “–build” flag:

[root@rhel61ref rlwrap-0.37]# ./configure --build=x86_64

This did the trick. After the configure command completed, all I needed to do was to “make” the application and “make install”. Now all I need to do is wait for Oracle to release 11.2.0.3 hopefully around OpenWorld and install it to my system. Until then I’ll have to work on understanding upstart…

Alternative

The alternative is to grab a RPM from a compatible source, such as EPEL (http://fedoraproject.org/wiki/EPEL), but that depends if you are willing to mix RPMs from different sources which may not be possible due to political reasons.