Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

select where binary field = 'true'?

26 views
Skip to first unread message

Alex

unread,
Nov 30, 2011, 11:08:20 AM11/30/11
to
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

Antony

unread,
Dec 12, 2011, 5:05:06 PM12/12/11
to
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 :)
0 new messages