Re: search on Oracle CHAR primary key column

[prev] [thread] [next] [Date index for 2004/08/25]

From: Jay Strauss
Subject: Re: search on Oracle CHAR primary key column
Date: 15:32 on 25 Aug 2004
> I need to interface with an Oracle table that has CHARs as primary key
> columns (there are two), but I've been unable to get any
> selects/searches to match anything unless I use search_like. I finally
> figured out it was probably because the datatype is being set to
> VARCHAR by default.

My guess is its a padding issue.  Oracle right pads strings with spaces to
the length of the column.  That is, if your pk_id is defined as char(10),
and
you store "AU" in that field, Oracle will save: "AU        " in the column (
which is why your search_like is working).

To make search work you'd have to pad it yourself (I'm sure someone has
a much slicker way but ugly coded like:

my $id = substr("AU"." "x10,0,9);
my $row = __PACKAGE__->search({id=>$id});

Jay

search on Oracle CHAR primary key column
Jim Brandt 14:19 on 25 Aug 2004

Re: search on Oracle CHAR primary key column
Adam Przygienda 15:25 on 25 Aug 2004

Re: search on Oracle CHAR primary key column
Jay Strauss 15:32 on 25 Aug 2004

Re: search on Oracle CHAR primary key column
Jim Brandt 14:43 on 26 Aug 2004

Re: search on Oracle CHAR primary key column
Tim Bunce 15:56 on 26 Aug 2004

Re: search on Oracle CHAR primary key column
Jim Brandt 19:28 on 27 Aug 2004

Re: search on Oracle CHAR primary key column
Tony Bowden 10:05 on 30 Aug 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52