View Full Version : Sybase produces different results


Pat Hartman
03-07-2002, 09:54 AM
I have a query that produces different results when run against a Sybase table than it produces when run against an identical set of data in an Access table. The query refers to three screen fields that are set on a form we use for filtering the result set. When E.DataEntryCompleteFlg and Forms!frmFilter!txtHiddenWork are both 0, correct results are returned. When the values are both -1, Sybase does not recognize the values as being equal.

SELECT E.CISCompanyNum, dbo_CISCompany.CISCompanyName, E.UWRespName, Year([ChangeEffDt]) AS ContractYear, s.last_nm & ", " & s.first_nm AS FullName
FROM dbo_CISCompany INNER JOIN (dbo_ERCContractExhibit AS E INNER JOIN dbo_tb_user AS s ON E.UWRespName = s.user_id) ON dbo_CISCompany.CISCompanyNum = E.CISCompanyNum
WHERE (Year(ChangeEffDt) = Forms!frmFilter!txtHiddenYear) AND

((E.UWRespName = Forms!frmFilter!txtHiddenUserId
Or IsNull(Forms!frmFilter!txtHiddenUserId) = -1))

AND ((E.DataEntryCompleteFlg=Forms!frmFilter!txtHidden Work Or IsNull(Forms!frmFilter!txtHiddenWork) = -1));

Alexandre
03-07-2002, 10:55 AM
Pat,
I don t know Sybase, so this is just a thought.
I believe you are talking about boolean values? Did you check if Sybase wouldn t use 0 for false and 1 for true instead of 0/-1 like Access?

Alex

[This message has been edited by Alexandre (edited 03-07-2002).]

Rich
03-07-2002, 10:58 AM
Might True/False work instead?

We have to stop bumping into each other like this Alex http://www.access-programmers.co.uk/ubb/smile.gif

[This message has been edited by Rich (edited 03-07-2002).]

Pat Hartman
03-07-2002, 11:18 AM
The field is defined as BIT in Sybase and it shows 0 or -1 when you look at the table. However, the ODBC may be translating the 1 to a -1 so that it can treat the field as a boolean. I was waiting for the DBA to change the datatype of the field to see if that was the problem when I saw your reply. It prompted me to do a little test and sure enough the value of true is 1.

This seems to be an ODBC bug. It shows the data in the column as -1 when it is actually 1.

Rich, True/False would probably have worked except that I am comparing two fields rather than a field with a literal. The value of one field turns out to be 1 (even though Access displays it as -1) and the value of the other is -1 so of course they did not compare equal.

Thanks guys. I'll get the DBA to change the datatype to numeric(1,0) and hopefully that will solve the problem.