Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Scott Zetlan" <scottzetlan at aol dot com>
Subject: RE: Sql or Sybperl advice needed
Date: Jun 18 2002 3:39PM

It's tough to suggest a good solution without knowing what data we're
modeling and what problem we're solving, but it sounds like some boolean
math is in order:

    ( (a is null and b is null) or (@my_range between a and b) )
    and ( (c is null and d is null) or (@my_range between c and d) )

might work.  Also, creating two instances of the test table in the select
statement (select ... from test_table one, test_table two) might be useful,
as might running two separate selects in a union/union all operation.


> -----Original Message-----
> From:
> []On Behalf Of Michael Peppler
> Sent: Tuesday, June 18, 2002 10:48 AM
> To: SybPerl Discussion List
> Subject: Re: Sql or Sybperl advice needed
> On Tue, 2002-06-18 at 07:27, Lee Wenzler wrote:
> > Sybperl hash advice needed:
> >
> >
> >
> > I'm using Sybase::Simple and need a method of selecting a row from a
> > table used to translate from one system to another where there are
> > matches of one more columns, but I want the row that has the most
> > matches (I'm hoping to use some type of hash table for this).  All of
> > the source columns can have null (don't care) values too. For example,
> > with a table that has these columns:
> The solution that I'd use would probably depend on how many rows match
> the minimal condition (i.e. a / b not null, or d/e not null if I
> understand correctly).
> If the number of rows is relatively small I might load the minimal
> condition to a hash or array of some sort, and then find the entry that
> matches my condition.
> You could also write a stored procedure that does this for you, but that
> would have to iteratively query the table until it got a hit, I think.
> Maybe someone else has a better idea on how to solve this sort of
> problem...
> Michael
> --
> Michael Peppler / /
> / ZetaTools, Inc /
> ZetaTools: Call perl functions as Sybase stored procedures!