Author Archive for marc Page 2 of 4



using cursors as OUT parameters in PL/SQL stored procedures

The system that I’ve been working on uses as a standard stored procedures that declare an OUT parameter through which a result cursor is “returned” to the caller. While it is easy enough to call the procedure and process the result set in Java, I occasionally want to call such a procedure from SQL*Plus. To do this, one must bind a suitably typed variable to the procedure’s output parameter, for example:

   SQL> var proc_res refcursor;
   SQL> exec foo.get_stuff (:proc_res);
   
   PL/SQL procedure successfully completed.
   
   SQL> print proc_res;
   
   DUM
   ---
   X

In this example package foo and procedure get_stuff are declared as:

   SQL> create or replace package foo is
    2 type cursor_out is ref cursor;
    3 procedure get_stuff (results out cursor_out);
    4 end foo;
    5 /
   
   Package created.
   
   SQL>
   SQL> create or replace package body foo as
    2 procedure get_stuff (results out cursor_out) is
    3 c1 cursor_out;
    4 begin
    5 open results for select * from dual;
    6 end get_stuff;
    7
    8 end foo;
    9 /
   
   Package body created.

printing PL/SQL debug output in SQL*Plus

Oracle Database provides the put_line procedure (in the dbms_output package) to print statements. This output is not, however, displayed by default in SQL*Plus; it must be enabled using:

   SQL> set echo on
   SQL> set serveroutput on

put_line can then be used as follows:

   SQL> declare
    2 x number;
    3 begin
    4 x := 3;
    5 dbms_output.put_line('x is ' || x);
    6 end;
    7 /
   x is 3
   
   PL/SQL procedure successfully completed.
   
   SQL>

this is a job for Super GRUB!

I’ve been evangelizing GNU/Linux where I work, but I was recently forced to revert my Linux/Windows dual-boot to a pure Windows installation and reclaim the Linux partitions for use by Windows.

After booting into Windows, I used the Logical Disk Manager to delete the ext3 and swap partitions and create an NTFS partition. All was well until my next reboot, when I was greeted with:

   GRUB Error 17

GRUB had been installed to load its configuration files from the Linux partition. Which I’d blitzed. I now needed some way to overwrite GRUB with the Windows bootloader. Traditionally this is achieved using fdisk by running:

   fdisk /mbr

With Windows XP, fdisk is available from the Recovery Console; boot from the Windows XP installation CD and follow the prompts until you are given the option to recover an existing Windows installation. Unfortunately – due perhaps to some quirk of how GRUB installed itself – the Windows Setup process blue-screened at the

   Setup is starting Windows

stage. I could have booted Linux using a LiveCD and re-installed GRUB with a configuration that simply booted into Windows, but I didn’t trust GRUB to be able to install its configuration files into an NTFS parition without trashing the partition. Enter the Super GRUB Disk.

The Super GRUB Disk is a nifty boot disk that makes it easer for a novice user to recover a system or experiment with GRUB without inadvertently rendering the system unbootable. Navigating the basic menus for booting a Windows partition gave me what I needed to get my system up and running. Using Super GRUB Disk version 0.9766 (baed on GRUB 0.97-os.1) the menu sequence was:

  1. Choose language & NO HELP
  2. <Language> Boot Disk (for me: English)
  3. Windows
  4. Boot from 2nd partition (Laptop)

Being a Dell, the first partition on my system is the Dell Utility partition and the second is the active NTFS partition, so this option was exactly what I needed. There are also options to boot from other hard disks, and to, of course, install the Windows bootloader (the equivalent of fdisk /mbr).

More information about the various options is available from the Choose language & HELP menu option, and from Herman’s Super Grub Disk Documentation, an excellent reference.

technicolour terminal

Ryan McGuire has a nice little post that describes how to enable the 256 colour display capabilities of terminal applications that support it. In short, make sure that an initialisation script like ~/.profile or ~/.bash_profile contains:

   export TERM=xterm-256color

To test, execute M-x list-colors-display in emacs.

On MacOS X one will need to install the ncurses package from macports. Unfortunately, the terminal emulator that ships with MacOS X – Apple’s Terminal.app – doesn’t support 256 colours; use iTerm.app instead.

making dot-files visible in MacOS X Finder

Like GNU/Linux, MacOS X treats files with names that start with a dot as hidden files. While "power users" will have no trouble accessing these files using Terminal.app or iTerm.app , it is sometimes handy to have them displayed in the Finder. A case in point: I recently wanted to restore a dot-file from a Time Machine backup, but the file was hidden in the Time Machine Finder window.
With some command-line-fu one can configure Finder to display dot-files:

   $ defaults write com.apple.finder AppleShowAllFiles TRUE
   $ killall Finder

To revert, simply flip the TRUE to a FALSE:

   $ defaults write com.apple.finder AppleShowAllFiles FALSE
   $ killall Finder

oracle database XE confined

I am currently empoyed to develop/maintain commercial software that is deployed on Oracle Database Enterprise Edition. However, to streamline my day-to-day activities, I’m using Oracle Database Express Edition (XE) in development.

Being somewhat lighter than its peer editions, XE is better suited to a desktop environment and I’ve managed to get it running in a memory constrained VMware Virtual Machine running Ubuntu GNU/Linux 8.04 (Hardy Heron) with 768mb RAM. It is not, however, what one would call a light-weight database and does require a few tweaks to get it to compensate for an environment where resources are scarce.

I’ve started a wiki page that details the various problems that I have encountered, and the solutions that I’ve found. As I encounter issues I’ll post updates in the form of comments.

emacs & slime for people like me

Peter Christensen has published his "Ultimate n00b SLIME/Emacs cheat sheet" as a Work In Progress. It’s a very handy quick reference.

vnc://

I have been delighted to discover that not only does Leopard (MacOS X.5) have a built-in VNC client, it supports screen-scaling out of the box. Connect to Server (Finder >> Go >> Connect to Server, or Command-K) has a handler for the vnc:// protocol handler that invokes Screen Sharing as a VNC client.

Apple win again.

Macworld has an article that outlines the power of Screen Sharing as more than just a VNC client.

punch clock: an introduction to objective-c

My first attempt at using Objective-C for something useful has produced Punch Clock, a simple application that one might use to record one’s activities for personal time management or later entry in a time-tracking system or timesheet.

While it is, as an application, little more than a skeleton of a prototype, it has enough useful functionality to give a flavour of Cocoa development in Objective-C. It features:

  • post-launch application initialisation through the use of a NSApplication delegate
  • an editable NSTableView
  • programmatic edits of a table cell
  • NSButtons that are enabled and disabled according to the state of the application

Those not completely disinterested can browse the source. It is hosted by Bitbucket as a Mercurial repository; retrieve it using:

   hg clone http://bitbucket.org/sinistral/punchclock