• Post Reply Bookmark Topic Watch Topic
  • New Topic

find method from database side in B&S

 
pramod karnani
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi All,
find method is given like this in instruction:
// 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".)
public int [] find(String [] criteria)



Here I am talking about search from database side not from User Interface

I implemented find method like this way:

If user will specify criteria array like this

criteria[0]="SubContractor name";
criteria[1]=null
criteria[2]=null
criteria[3]=null
criteria[4]=null
criteria[5]=null


then find method will return record number array of those records those are matches with criteria[0]="SubContractor name"
since only criteria[0](sub contractor name ) is specified.

If user will specify criteria array like this

criteria[0]="SubContractor name";
criteria[1]="city"
criteria[2]=null
criteria[3]=null
criteria[4]=null
criteria[5]=null


then find method will return record number array of those records those are matches with this condition (criteria[0]="SubContractor name" OR criteria[1]="city")
since only criteria[0](sub contractor name ) and criteria[1](city) are specified.


If user will specify criteria array like this

criteria[0]="SubContractor name";
criteria[1]="city"
criteria[2]="services"
criteria[3]=null
criteria[4]=null
criteria[5]=null


then find method will return record number array of those records those are matches with this condition (criteria[0]="SubContractor name" OR criteria[1]="city" OR criteria[2]="specialities")


so on.

It is like OR condition of criteria string array elements.

is it okay?

Regards
Pramod

 
Roberto Perillo
Bartender
Posts: 2273
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Pramod!


It is like OR condition of criteria string array elements.

is it okay?


That's exactly it!
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!