Year: 2005

Ruby/OCI8, Oracle and ORA-12705

After installing the Ruby/OCI8 module on a Windows XP installation where sqlplus is working fine I got the following error when testing the connection in irb:


irb(main):012:0> cn = OCI8.new("username","password","database")
OCIError: ORA-12705: invalid or unknown NLS parameter value specified
from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:158:in `begin'
from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:158:in `initialize'
from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:158:in `do_ocicall'
from c:/ruby/lib/ruby/site_ruby/1.8/oci8.rb:158:in `initialize'
from (irb):12:in `new'
from (irb):12
from :0

This one really took me several hours of google-hunting, finding 0 direct solutions. I was almost throwing my hat in the ring when I finally found the solution.

The Problem
In this case the ‘NLS parameter’ I was having a problem with turned out to be NLS_LANG.

This parameter is supposedly set during installation (I can’t remember choosing this, but this must be the only Oracle client installation I’ve ever done on MS Windows). The ORA-12705 error was cause by my client Ruby/OCI8 sending an incompatible NLS_LANG language parameter when connecting with this specific Oracle db.
Sqlplus, enterprise manager,… were all working fine.

Where is NLS_LANG stored on the client ?
The value was in my case stored in 3 different locations in the windows registry, always in a key ‘NLS_LANG’, once at HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE, and 2 more times in sub-keys of this location. Just do a search in regedit for ‘NLS_LANG’ and you’ll find the culprits. 1 of these NLS_LANG had the value ‘NA’, the other 2 were ‘DUTCH_BELGIUM.WE8MSWIN1252’.

If you want to test if this is the source of your issue, then apparently you can override this value using an ‘NS_LANG’ environment variable. To test this, just do ‘set NLS_LANG = ‘ in your dosbox before starting irb.

How do I know what language the Oracle db expects ?
Open a connection to the db with sqlplus (or whatever it is you’re using) and issue the following:

SQL> select USERENV('LANGUAGE') FROM DUAL;

Result:

USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.WE8ISO8859P1

To view all NLS parameters, issue:

select * from NLS_DATABASE_PARAMETERS;

When doing ‘set NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1’ before starting irb, connecting to the db went fine.

Will this work with rails ?
I tried ‘set’ting NLS_LANG before starting webrick, but to no avail. I really had to change registry values for rails to work when running onder webrick.
I guess (hope) it will be the same when running under a more production-level server too.

What if I need to connect to several different db’s which expect different language settings ?
God knows.
I’d start by trying to set all NLS_LANG registry entries to ‘NA’. If that doesn’t work, I’d try to find out if it’s possible to set this as a parameter when connecting. But how you would do this in Rails: ???

Please let me know if you find out!

installing fxruby on ubuntu

Did you get the following error on your ubuntu 5.10 when installing fxruby (or probably any other gem) via rubygems:

Building native extensions. This could take a while...
extconf.rb:4:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:4

then you probably need to install the ruby1.8-dev package.

Komodo with Ruby support

By the way… I started looking into ruby a while ago (after checking out what all the fuss concerning ‘Ruby on Rails’ was all about and being pleasantly surprised by both Rails and Ruby).

Now, seeing that Activestate Komodo is my favorite tool for both perl and php (it even works on both windows AND linux… and even mac os x, but I don’t use os x (yet)), I was pleasantly surprised (again) to see the next version would have ruby support.

Check the beta/alpha here.

Installing scons on Fedora Core 3

I downloaded the rpm scons-0.96.1-2.1.fc3.rf.noarch.rpm from http://dag.wieers.com/packages/scons/

If scons (I needed it for the kdissert mind mapping tool), gives the following error:

Checking for uic : uic was not found - set QTDIR put it in your PATH ?


You probably need to install the Qt gui toolkit headers with ‘yum install qt-devel’

If you get:

Checking for the kde includes : The kde includes were NOT found

You need a ‘yum install kdebase-devel’ (or at least something else this is dependent on)

Hope this help someone some minutes googling or maybe prevents some hairpulling. In any case, kdissert is a nice tool though. I was just evaluating a commercial mindmapper on windows (Visual Mind) when it caught my eye. It’s got basically the same features so I guess I can stop evaluating it. I must admit Visual Mind looks real nice, but my wallet can’t see the difference.

I just wonder… why is it you can’t have 2 branches arrive at the same node… say, you’ve got 2 possible paths giving the same result and you haven’t made up your mind yet about which one you’ll be using. This doesn’t seem to be possible in either kdissert or Visual Mind.

FXRuby – require keeps returning false

You installed the fxruby gem, installed the FOX GUI library, checked dependencies, compiled and rechecked everything several times again, breaking your head why the ‘quick sanity check’ (require ‘fox14’) as suggested on http://www.fxruby.org/doc/gems.html keeps returning ‘false’ ?

Well, instead of:

require 'rubygems'
require 'fox14'

try this:

require 'rubygems'
require_gem 'fxruby'

Supposedly both should work, but somehow only the ‘require_gem’ way works for me.

…I hope this saves some people some headaches…

Problem booting copied Fedora partition with Grub

Situation:
After copying a Fedora Core 3 partition to a new harddrive (using Knoppix) I was at first unable to boot the new partition (using Grub).
I got the following error:

switchroot: mount failed: 22
umount /initrd/dev failed: 2
Kernel panic - no syncing: Attemped to kill init!

I vaguely remembered having this situation before, but really couldn’t remember how I dealt with it.
Googling around didn’t really produce much results at first (only more people having the same issue, but no real answers), but I was able to puzzle a solution together.

Problem:
It turned out that both my grub.conf and /etc/fstab files contained a reference to a ‘LABEL’ that seemed to be missing. Relevant entry of grub.conf:

title Fedora Core (2.6.9-1.667)
root (hd0,5)
kernel /boot/vmlinuz-2.6.9-1.667 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.9-1.667.img

entry of fstab:

LABEL=/ / ext3 defaults 1 1

Solution:
For as far as I understand you’d normally put a device here (in my case I would have been able use /dev/hda6 in both files), but the ‘LABEL=/’ here means as much as ‘use the partition with label /’.
Putting a label on a partition is possible using ‘e2label’. I labelled my /dev/hda6 as follows (using Knoppix):

su
mount -o dev,rw /mnt/hda6
(to mount my new partition writable)
e2label /mnt/hda6 /

Apparently it’s also possible to set the partition label/volume name using ‘tune2fs’, but since the above worked for me I didn’t really look into this.

Dew-NewPHPplinks category insert made easier

A while ago a friend of mine wanted to run an ‘internet directory’ using a php/mysql based script called Dew-NewPHPLinks.

He wanted to add a whole bunch of categories but the online standard way to do this really is a bit cumbersome to add more than a handfull at a time. I helped him out by writing a little php script that adds categories from a txt file with a fairly straightforward layout.

You can find the script here.

I really can’t remember the exact purpose of formatting/parameters, but the script itself contains a little example commented in which I remember was straightforward at the time.

Remember to change the path to your categories-textfile and your mysql connection parameters as needed.

Aloha!

…and welcome to my (=Piet Hadermann) ‘blog’.
Well, actually… I’m planning on using this more as an automated notepad to preserve various notes (probably all IT/development related, since I don’t usually keep notes concerning anything else) for the future.

I tended to keep notes on paper. Although paper has some big advantages (extreme portability, low power requirements, really nice tactile user interface) I was always unable to find the notes I needed later on. Unfortunately Google also turned out to be unable to index my notes. I guess their bot was unable to decipher my handwriting or decided it was spam.

I also use a ‘private’ wiki for various notes and brain-dumps, but as from now on I’m planning on dumping any info that might benefit someone else right here.

In the past I’ve often stumbled upon blogs and web pages of people doing just this when I was looking for a way to solve a problem or some information. This is my way of giving something back without really having to put in any extra effort (I especially like the ‘no extra effort’ part).

blahblah yadayada and so on… (you should really get a hobby if you’ve read this far)