|
|
sybperl-l Archive
Up Prev Next
From: Michael Peppler <mpeppler at peppler dot org>
Subject: RE: Sql or Sybperl advice needed
Date: Jun 19 2002 2:28PM
On Tue, 2002-06-18 at 19:11, Matthew O. Persico wrote:
>
> Or what about:
>
> select
> Prod_ID, Account_Type, Rate_Code, Product_Line, Wt_Min, Wt_Max
> from
> info_table
> where
> @acct_type = isnull(Account_Type,@acct_type)
> and @rate_code = isnull(Rate_Code,@rate_code)
> -- ditto for Product_Line
> and @weight bewteen isnull(Wt_Min,@weight)
> and isnull(Wt_Max,@weight)
> order by --all the columns, either asc or desc, whichever puts the NULL row AFTER the non-nulls
Neat idea - you can use isnull() in the order by clause to achieve the
correct order.
>
> Then just use the Sybperl equivilent of DBI's selectrow_array() if there is one. If not, fetch one row and cancel the query. You should then have your data.
That's just a normal fetch (ct_fetch() for Sybase::CTlib)
Michael
--
Michael Peppler / mpeppler@peppler.org / http://www.mbay.net/~mpeppler
mpeppler@zetatools.com / ZetaTools, Inc / http://www.zetatools.com
ZetaTools: Call perl functions as Sybase stored procedures!
|