On Sep 24, 6:30 pm, David Jenkins <[email protected]> wrote:
> I'm using mysql; I create a dataset via this command:
>
> dataset = DB['call GetInstRecs(\'MSFT\',  \'S\')']
>
> where, obviously, GetInstRecs is a stored procedure in mysql which returns a
> field named "weekendday", among others.  It's of type smallint.
>
> When I try this:
>
> dataset.map do |r|
>   if (r[:weekendday] == 0)
>     out_str = "***" + r[:weekendday].to_s  + "***"
>     puts out_str
>   end
> end
>
> I get no records at all. If I change the "if" to
>
>   if (r[:weekendday].to_i == 0)
>
> I get all records, regardless of what weekendday is, and they all look like
> "***0***" and "***1***", which tells me that the values are 0 and 1, and
> that the to_s values are "0" and "1".
>
> So therefore I also tried
>
>   if (r[:weekendday].to_s == "0")
>
> which yields no records at all.
>
> I'm stumped.

Try the following:

dataset.map do |r|
  p r
  if (r[:weekendday] == 0)
    out_str = "***" + r[:weekendday].to_s  + "***"
    puts out_str
  end
end

The "p r" will output the contents of the hash in inspect format, so
you should be able to see what the values actually are.

Jeremy
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to