Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Future proofing my sql
Thu, May 25 2006 9:26 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

I know I'm not allowed to ask about ElevateDB so I'm not Smiley

I want to make sure that the SQL statements I'm writing now are as future proof as possible so I'd like answers to the following (sorry its that null again)

If I want to test for wether or not a field has text in it (and in my case an empty string (ie quote quote) qualifies as not having text) do I have to write

IF stringfield IS NOT NULL AND stringfield IS NOT ''

or would

IF LENGTH(stringfield) > 0

be better

I seem to remember from other posts that

IF integerfield <> 0

is sufficient - is that right or do I need

IF integerfield IS NOT NULL AND integerfield <> 0


and for a boolean field simple

IF booleanfield

or

IF NOT booleanfield

is right

Sorry to ask (I know how heartily sick of null we all got) but I'm writing a wadge of sql and I want it to work with the future product.

Roy Lambert
Thu, May 25 2006 7:26 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< If I want to test for wether or not a field has text in it (and in my
case an empty string (ie quote quote) qualifies as not having text) do I
have to write

IF stringfield IS NOT NULL AND stringfield IS NOT ''

or would

IF LENGTH(stringfield) > 0

be better >>

If you want to avoid issues with NULLs, then you can't use a simple
equality/non-equality operator, meaning that the LENGTH() function will be
the solution for you and will work with both NULL and non-NULL string
columns.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image