![]() ![]() ? "Bobby" = "Bob " & Bobby starts with Bob but there is a trailing space there, FALSE ? "Bobby" = "Bob" & Bobby starts with Bob, so TRUE ? "Bobby" = "B" & Bobby starts with B, so TRUE With SET EXACT OFF, read the comparison as "does string at right start with the string at left"? They are compared up to the right string's length. SET EXACT has no effect on comparisons made within SQL queries. SET ANSI (Default is OFF and effects comparisons in SQL only.SET EXACT (Default is OFF and effects regular comparison's - those except SQL).In VFP basically two settings effect the comparison: I have seen and demonstrated that it fails in many cases, but then I stopped trying to use it much before VFP9 version, it might be consistent now, I really don't know.Ĭonsidering we covered inequality cases with strings, the tricky one is the equality case. If you would use collations, then keep in mind to check it first when you experience something that is very unexpected regarding character data. I suggest you not to use collations and stick with default 'MACHINE'. Personal advice: Collations in VFP has never been reliable enough. With collation setting other than default machine you are also implying a case insensitivity on comparison ( do NOT trust this for equality ): set collate to 'GENERAL' When you change the collation to something else then you get the comparison based on that collation's sort order. The default for collation is 'machine' and this is what you get then. If two strings are not equal, so far so good, provided that you didn't change any defaults then they are compared based on their ASCII values. However VFP to has some collation support and makes case insensitive comparison. In VFP though you only get those where casing matches. Select * from myTable where Country = 'Turkey' For example in postgreSQL, or MS SQL Server on a table created with case insensitive (CI) collation: select * from myTable where Country = 'TURKEY' This is not the case with many databases where the default is to use a case insensitive collation. Important: VFP strings are case sensitive. If they are not equal, then we might think about the operators >, =, <=, right? With strings it is confusing when two strings are considered equal. So it is quite understandable slight nuances might confuse the newbies easily.Ĭomparison is basically about being equal or not. Many years back, I have even seen some really advanced members in the community who weren't yet aware how these operators work in VFP. It doesn't work as in other languages and/or databases and unique to VFP (and maybe to some other xBase language). They are identical properties wiseĬomparison of character data type, aka comparison of strings is the most confusing one in VFP. * They are different objects, but do they have any difference in their properties? * remember we are comparing their references in memory ? Date() m.o2 & this would work too but likely you would never use For example, you would get an error if you try to compare a Date to an Integer.ĭate and Datetime can be compared, although they are different types, VFP does the conversion implicitly for you. Not equal to (all 3 operators act the same way, choose your favorite)Īlthough you can use these with all data types, there should be a type compatibility between the operands. ![]() ![]() Let's start with a list of relational operators: Operator Moreover, the behavior might look awkward, you don't get what you expect unless you know what effects the results. Well, the complexity comes from the fact that, they operate on any types be it a numeric, date, datetime, logical or a string, and even on objects. List operations and a few more lines as if it is all about those Interestingly though, if you check it in VFP help you only see a short Relational operators are also known as Comparison operators, they are used to compare things.Ĭomparison result is boolean false or true. Of all the operators, relational operators are the most complex ones, that is why we left them to the end.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |