Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A null value in criteria[n] matches any field value

 
Alejandro Sandoval
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI guys.

I�m a little confused with the requirements of the find() method, it says �Returns an array of record numbers that match the specified criteria. Field n in the database file is described by criteria[n]. A null value in criteria[n] matches any field value. A non-null value in criteria[n] matches any field value that begins with criteria[n]. (For example, "Fred" matches "Fred" or "Freddy".)�

It means that if there is a null value in the criteria all records will be return? Because a null value matches any field value:

Criteria = {�Fred�, null, null, null, null, null} returns all records because of the nulls or it just returns records that starts with �Fred�?
 
Paul Murphy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alejandro

I'm not sure it you have the same sun instructions as myself, but the following was a criteria for the UI....

It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user

So the only fields your are required to search on are name and location.

So if you have criteria{"Fred",null} then all contractors who name begins with fred in all location will be returned.

If you have criteria{null,"Smallville"} then all contractors in location smallville will be returned.

Hope this helps
 
Gilles Marceau
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Alejandro,

I think the key is the assignement sentence "A null value in criteria[n] matches any field value". In my opinion, this statement stands for the
field[n] only. Having a null value at criteria[n] doesn't mean
the result is the whole database, it does just mean that there is no
filtering process to do on the records field[n].

Hope this help

Gilles
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic