I've been trying and failing (or at least partially) to extract a single
field from a row retrieved from the database.
this is what I'm wanting to do....
Extract from the table the last record that matches the passed parameters
nos and date.
the sequel code I've tried lots of things but either get this sort of value
put to the console...
nil [1]
#<Sequel::MySQL::Dataset:0xb6ff8320> [2]
commentstest entrydate19/08/2010id37cust_code1000 [3]
now the last line above has valid data in it. broken down it's ..
* Column value*
comments test entry
date 19/08/2010
id 37 <---------Auto incremental indexed field
cust_code 1000
[1] a = @db[:guard_run].filter(:cust_code => nos, :date =>
date).order(:id).last
puts a
[2] a = @db[:guard_run]
puts a
[3] a = @db[:guard_run].to_a
puts a
Ultimately I want the last record found where the date and customer code
match I really only want to use the data found in comments field.
When i do achieve [3] I've tried things like...
puts a.[:comments]
puts a.[:comments].to_s
puts a.filter[:comments]
to try and ONLY have the comments print onto the console to no avail.
the other thing I need to cover off is when there are no comments (entries
in the table for a customer) I want to pass back my own default comment.
Yes I could have it put in as a default entry but this is a waste of disk
space when i could use a simple test and when needed pass it back.
I've also tried @db[:guard_run].order_by(:id).last(:cust_code=>nos,
:date=>date).
I know it's something EVRY basic and looked over and over the RDOCS and
other documentation at sequel ruby fore but nothing seems to be sinking in.
even tried doing multiple steps like getting all values and then filtering
with no joy.
any help be appreciated by this newbie.
cheers,
dave.
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.