This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getRecord Vs readRecord usage in criteriaFind()

 
Panku Panchal
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm right now planning to write criteriaFind() method and I find getRecord() and readRecord() both methods useful. Can anybody tell me why I should use getRecord() or readRecord().
Which will be efficient and easy to code?
How can I make use of find() method?
Please do comment on this.
Panku
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11833
181
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Panku,
I'm right now planning to write criteriaFind() method and I find getRecord() and readRecord() both methods useful. Can anybody tell me why I should use getRecord() or readRecord().

Have a think about what criteriaFind() returns and what readRecord() and getRecord() returns - can you see any simplification of your code if you use one versus the other?
How can I make use of find() method?

You may not have to use this for your criteriaFind - I certainly didnt.
But I did use it elsewhere in my program.
Regards, Andrew
[ April 29, 2003: Message edited by: Andrew Monkhouse ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getRecord calls readRecord.
Look at the implementation of these two methods and see if you can see what the difference is between them. clue: Look at the signature, and why would getRecord call readRecord. What are the purposes of these methods?
use getRecord by the way.
Mark
 
Panku Panchal
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ooops....Mark I overlooked it!!!
My mistake!
Andrew..thank you for the reply....I understood.
I want to know more about criteriaFind....am I suppose to find the best possible route for the user or just all available routes? What I mean do I need to sort the result considering distance, time etc.?
Also right now I'm thinking of taking command line input for testing my criteriaFind...also my parsing method works for input like
1."Carrier='SpeedySAir',Origin='SFO'"
2. Carrier=SpeedyAir, Origin=SFO
3. Carrier=SpeedyAir Origin=SFO
I want to know is there any restriction for user input format ? or do I have to restrict user from not using quotes and commas in search?
When I'll start working on GUI, I'll accept input in textbox or etc...then when will I use this kind of input?
1."Carrier='SpeedySAir',Origin='SFO'"
I'm really confused....
Please do help me in this method.
Panku
 
Panku Panchal
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more thing about db.db field names ,
those doesn't match with search criteria provided by sun.For example I've db.db files with field names Origin airport values, Destination airport values and carrier values.
I;m trying to match thses fieldnames with my index/values pairs created by search criteria
"Carrier='SpeedyAir', Origin='SFO'"
It doesm't match and returns me garbage values.
How should be my search criteria and parsing method?
Do comment on this ....
Panku
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my submission I did not use the quotes around the value. Also you will want to use JComboBoxes for the user to select their criteria. Do not give them Textboxes to enter values as you will lose points if you do.
The search will bring in all records that match the criteria, no logic for the shortest route needed. Just the matching records.
Mark
 
Panku Panchal
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,
Ok...got some idea. So I have to bulid String criteria myself right? So can I consider complete fieldname as stored in db.db? Like my second post...
One more thing about db.db field names ,
those doesn't match with search criteria provided by sun.For example I've db.db files with field names Origin airport values, Destination airport values and carrier values.
I;m trying to match thses fieldnames with my index/values pairs created by search criteria
"Carrier='SpeedyAir', Origin='SFO'"
It doesm't match and returns me garbage values.
How should be my search criteria and parsing method?
Do comment on this ....
Panku

so my criteria string will be
"origin airport value='SFO',destination airport value='NY'"
For the current code i have I can parse as many fieldNames as user can input with the above quotes and comms format. Is it valid...?
Panku
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11833
181
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Panku,
about db.db field names , those doesn't match with search criteria provided by sun

I think this is situation normal.
Check your instructions, mine state:
In the event of an invalid field name being provided as part of the criteria the behavior of this method is the same as if no records matched correctly specified

So if someone called my code with the criteria given as an example by Sun, they would get back zero results.
As Mark suggested: use JComboBoxes to let the user choose the search values. Then build the search criteria string yourself. That way your column names will always match those in the database.
Regards, Andrew
 
Panku Panchal
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Andrew,
got the solution.
Will post more difficulties as they appear.
Panku
 
Arun Bommannavar
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Panku Panchal:

Also right now I'm thinking of taking command line input for testing my criteriaFind...also my parsing method works for input like
1."Carrier='SpeedySAir',Origin='SFO'"
2. Carrier=SpeedyAir, Origin=SFO
3. Carrier=SpeedyAir Origin=SFO
I want to know is there any restriction for user input format ? or do I have to restrict user from not using quotes and commas in search?

Panku


Panku,
My instructions say
"Criteria take the form of a comma separated list of ....."
So, the following would not be right
3. Carrier=SpeedyAir Origin=SFO
Regards
Arun
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic