Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Boolean datatype

2 posts in Product Futures Discussion Last posting was on 2003-03-31 16:03:43.0Z
Olivier Posted on 2003-03-31 13:09:14.0Z
From: "Olivier" <ociteau-NOCANSPAM@yahoo.fr>
Organization: 212.234.59.104
X-Newsreader: AspNNTP 1.50 (C I Host)
Subject: Boolean datatype
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-ID: <OTSl7a49CHA.273@forums-2-dub>
Newsgroups: sybase.public.ase.product_futures_discussion
Date: Mon, 31 Mar 2003 05:09:14 -0800
NNTP-Posting-Host: 66.221.40.1
Lines: 7
Path: forums-1-dub!forums-master.sybase.com!forums-2-dub.sybase.com
Xref: forums-1-dub sybase.public.ase.product_futures_discussion:1093
Article PK: 95332

I wish there were a boolean dataType.
Not for use in table (we can use bit or int) but for T-SQL.

Instead of
if <my condition>
select @flag=1
else
select @flag=0

i wish i could write :
Select @flag = <my condition>
http://www.bretzelforbush.com/


Sherlock, Kevin Posted on 2003-03-31 16:03:43.0Z
Message-ID: <3E8866DD.77C4831A@qwest.com.nospam>
Date: Mon, 31 Mar 2003 10:03:43 -0600
From: "Sherlock, Kevin" <ksherlo@qwest.com.nospam>
Reply-To: ksherlo@qwest.com.nospam
Organization: QWEST Wireless
X-Mailer: Mozilla 4.79 (Macintosh; U; PPC)
X-Accept-Language: en,pdf,ko
MIME-Version: 1.0
Subject: Re: Boolean datatype
References: <OTSl7a49CHA.273@forums-2-dub>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.ase.product_futures_discussion
NNTP-Posting-Host: np45.qwest.com 155.70.39.45
Lines: 27
Path: forums-1-dub!forums-master.sybase.com!forums-2-dub.sybase.com
Xref: forums-1-dub sybase.public.ase.product_futures_discussion:1095
Article PK: 95335

Most any "condition" can be expressed as some combination of functions
which return a zero or one. These are known as "characteristic"
functions. There is some interesting reading on this subject in:

"Optimizing Transact-SQL: Advanced Programming Techniques" - David
Rozenshtein, PH.D., Anatoly Abramovich, PH.D., Eugene Birger, PH.D;
ISBN: 0-9649812-0-3

for example:

if ( @a >= @b )
select @flag = 1
else
select @flag = 0

-- Versus --

select @flag = sign(1+sign(@a-@b))

You should also make use of the "case" statement (in ASE 11.9.x and up)
since it's a little more self documenting:

select @flag = case
when @a >= @b then 1
else 0
end

Olivier wrote:
>
> I wish there were a boolean dataType.
> Not for use in table (we can use bit or int) but for T-SQL.
>
> Instead of
> if <my condition>
> select @flag=1
> else
> select @flag=0
>
> i wish i could write :
> Select @flag = <my condition>
> http://www.bretzelforbush.com/