dbTalk Databases Forums  

select where binary field = 'true'?

sybase.public.ase.general sybase.public.ase.general


Discuss select where binary field = 'true'? in the sybase.public.ase.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Alex
 
Posts: n/a

Default select where binary field = 'true'? - 11-30-2011 , 10:08 AM






Hi, I'm enhancing application which works with MSSQL and Oracle to
also do Sybase - simple right?

One oddity came up, and I can't believe my eyes:
A field which is declared as 'bin' in Sybase cannot be compared to
'True' (it has to be compare to 1)
For example:
create table alex_test ( [active_ind] [bit] default 0 NOT NULL , mynum
varchar (255))
insert into alex_test(mynum) values('one')
select * from alex_test where active_ind = 'false'
drop table alex_test

The above works in MSSQL (and similar statements work in oracle, just
different syntax), but in Sybase, I get error:
Implicit conversion from datatype 'VARCHAR' to 'BIT' not allowed.
Use the CONVERT function to run this query.

Is there any option to turn on to allow this conversion to happen auto-
magically?
It just seems odd that both MSSQL and Oracle do it, but Sybase does
not.

Thank you
Alex

Reply With Quote
  #2  
Old   
Antony
 
Posts: n/a

Default Re: select where binary field = 'true'? - 12-12-2011 , 04:05 PM






Nope, Sybase is Sybase - not MSSQL or Orable

You could try this:

declare @false bit
select @false = 0
create table alex_test ( [active_ind] [bit] default 0 NOT NULL , mynum
varchar (255))
insert into alex_test(mynum) values('one')
select * from alex_test where active_ind = @false
drop table alex_test

That's about as close as you'll get

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.