FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour for Mr. Nages ADO SELECT for logical fields
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM
for Mr. Nages ADO SELECT for logical fields
Posted: Sun Jun 21, 2015 09:24 AM
Dear Mr. Nages,

In ADO, when issuing SELECT * FROM WHERE FIELDACTIVE = TRUE, this will work under MySQL but will fail under MSSQL, as requieres 'TRUE', with ' required.

How do I write all sql commands for being compatible for all RDBMS?.

Thank you.
Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: for Mr. Nages ADO SELECT for logical fields
Posted: Sun Jun 21, 2015 10:57 AM

Elvira,

Try SELECT * FROM WHERE FIELDACTIVE = 1 or SELECT * FROM WHERE FIELDACTIVE = 0

Regards

Antonio H Ferreira
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: for Mr. Nages ADO SELECT for logical fields
Posted: Sun Jun 21, 2015 07:27 PM

I agree with AHF

Regards



G. N. Rao.

Hyderabad, India
Posts: 518
Joined: Fri Jun 29, 2012 12:49 PM
Re: for Mr. Nages ADO SELECT for logical fields
Posted: Sun Jun 21, 2015 08:01 PM

Mr. Nages,

And this will be valid for all RDMBS?.

Posts: 838
Joined: Fri Feb 10, 2006 12:14 PM
Re: for Mr. Nages ADO SELECT for logical fields
Posted: Sun Jun 21, 2015 09:44 PM

Elvira,

As far as I know besides ADS there inst any support in any SQL server for Boolean type.
Normally we use Number (Oracle) or Bit all others so I think it would be safe to use 1 or 0.

Regards

Antonio H Ferreira
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: for Mr. Nages ADO SELECT for logical fields
Posted: Sun Jun 21, 2015 09:58 PM

Works for those RDBMSs which support BIT datatype to represent boolean values, eg mssql, mysql, access, etc. that too if you choose BIT datatype for the field to represent boolean values. ADO recognizes these BIT fields as adBoolean,

Well known exception is Oracle, which does not have BIT or BOOLEAN field type. With oracle, I personally use NUMBER field with 1 or 0. But when we work with tables created by others, we should keep in mind that the general practice of Oracle community for ages is to use 'Y' and 'N'. (I consider this unsafe and also experienced it. But we can't change their age old habits)

I understand Postgre has a boolean field type. Not sure about postgre, informix, etc

Personally I use =0 or <> 0 instead of =0 and =1.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion