Making TextMate and sqlplus play nice

Posted by Jesper on August 17, 2007

As described in the Calling TextMate from Other Applications chapter in the TextMate Manual

There is one command which does not support giving arguments in the EDITOR variable, it is crontab (which is sort of obsoleted by launchd). If you need to use it, you can create a symbolic link to mate with a _wait suffix which implies -w.

Well, as I found out a while ago, there’s another command that has the same problem: sqlplus. But if you follow Allan’s instructions, you can make TextMate work with sqlplus:

ln -s mate ~/bin/mate_wait   # run this once to create the link
export EDITOR='mate_wait'    # use in your ~/.bash_profile

Assuming you’ve already created a symlink to mate and that ~/bin exists (you could also use /usr/local/bin or some other preferred location). Now, in sqlplus simply type ed or edit as usual, and your commandline will open up in TextMate. Yay, one less reason to ever edit any text outside of TextMate.

Tips for Optimizing Rails on Oracle

Posted by Jesper on June 10, 2007

Just found a very nice article, Tips for Optimizing Rails on Oracle, on OTN (Oracle Technology Network). Definitely worth reading if you are working with Rails and Oracle:

In this article you dug a bit into how connections to an Oracle database are configured in a Rails application, and you have seen how the framework has been updated in the 1.2 release to have better performances thorough the use of the cursor_sharing and prefetch_rows parameters (while waiting for a real bind variable implementation).
You have also examined the Rails migration commands that are relevant to tuning the database (specially creating/removing indexes).
Finally, as you’ve learned, a good understanding of both how Rails builds the SQL from the code and how the database executes them is needed to get the best performance. The provided plugins should help here.

In sqlplus heaven with gqlplus

Posted by Jesper on December 17, 2006

I just found gqlplus today when looking for a way to enable command-line history in the SQL*Plus command that comes with Oracle’s Instant Client:

gqlplus is a drop-in replacement for sqlplus, an Oracle SQL client, for UNIX and UNIX-like platforms. The difference between gqlplus and sqlplus is command-line editing and history, plus table-name and column-name completion. As you know if you have used sqlplus, it is notoriously difficult to correct typing errors and other mistakes in your SQL statements. sqlplus does give you ability to use external editor to edit a statement, but only the last statement you typed. gqlplus solves this problem by providing the familiar command-line editing and history as in tcsh or bash shells, and table/column-name completion, while otherwise retaining compatibility with sqlplus.

To install on OS X, simply download, untar and do the usual configure/make ritual, with --disable-shared passed to configure (see this page for details but note that it’s no longer necessary to patch gqlplus):

$ ./configure --disable-shared
$ make

and then move the binary to /usr/local/bin. You may want to pass -d to gqlplus, to disable column-name completion, as it can take quite a while to load the meta data required, but otherwise gqlplus is truly a joy to use.

Update 2009-03-10:
If you want to substitute all calls to sqlplus with gqlplus, add an alias to your .profile (or .bash_profile):

alias sqlplus='gqlplus'    # with auto-completion 
alias sqlplus='gqlplus -d' # without auto-completion

Oracle Bundle for TextMate, Preview

Posted by Jesper on September 25, 2006

After reading The Pragmatic Programmer this summer, I’ve been trying to follow some of their tips, one of them being

Tip 22: Use a Single Editor Well
Choose an editor, know it thoroughly, and use it for all editing tasks.

My editor of choice is TextMate, one of the very first applications I bought for my Mac. I’ve been using it more and more lately, but unfortunately there’s no support for working with Oracle databases. The supplied SQL bundle works only with MySQL and Postgres, and Google wasn’t any help in finding a bundle specifically for Oracle.

After spending a few hours looking into what these TextMate bundles are, it turns out they’re very, very nifty and it’s not all that difficult to create your own. So, without tiring you with more chatter, I present my first TextMate bundle, the Oracle Bundle.

I could possibly have added Oracle functionality to the existing SQL bundle, but there didn’t seem to be a lot of overlap between MySQL/Postgres and Oracle in terms of the code implementing the bundles, so I decided to create a standalone bundle. So far, it’s only got a few basic features, but I’m hoping to add more as time allows for it. The syntax just piggybacks on the SQL syntax from the SQL bundle, and I haven’t added any support for PL/SQL.

This “preview” has the following commands:

Oracle Bundle Preview

Go ahead and grab your copy here.

Edit Page bookmarklet, Updated for Portal 10.1.4

Posted by Jesper on April 17, 2006

With the release of Oracle Portal 10.1.4, Oracle replaced the URL format

with the somewhat nicer

On top of this you may add rewrite rules to your page groups, so that you can in fact end up with some fairly nice URLs, that are both speakable and search engine friendly. The URLs are constructed from the page group name and page name, so don’t forget to update the names of your pages and page groups, to remove spaces and other unwanted characters in the URLs.

Unfortunately my Edit Page bookmarklet didn’t work with the new URL format, so here’s an updated version that works with both 10.1.4 and older versions:

Bookmark this link: Edit Page, to add the updated bookmarklet.

Edit Page bookmarklet

Posted by Jesper on December 08, 2005

Here’s a quick little tip for Oracle Portal. If you’re tired of adding “&_mode=16” to the URL of pages without the standard “Edit Page” link, you can save yourself some keystrokes by adding the following bookmark in your browser:

(bookmark this link: Edit Page, to create the bookmark)

Now, on any (Oracle Portal) page you simply select your bookmark, and the page reloads in edit mode. If you add the bookmark to your bookmarks toolbar, you can enter edit mode with just a single click.

Oracle9iAS Portal And Discoverer Integration

Posted by Jesper on July 15, 2004

  • Also, patch corrects many of the minor problems in the initial release.

    Discoverer 9.0.2 Known Issue:
    Discoverer With mod_osso And Portal Fails With “HTTP Error 403 – Forbidden”

    Use this as a workaround:

  • Stop OPMN <$BI-FORMS_ORACLE_HOME>/opmn/bin/opmnctl stopall
  • Modify <$BI-FORMS_ORACLE_HOME>/Apache/Apache/conf/mod_osso.conf and set OssoIPCheck off.

  • NOTE: The $ORACLE_HOME here is the BI-Forms Oracle Home, not the Infrastructure Oracle Home
  • Restart OPMN <$BI-FORMS_ORACLE_HOME>/opmn/bin/opmnctl startall