here's one of the outputs, based on your suggestion:

{:pricedate=>2009-08-19 00:00:00 -0400, :holiday=>0, :weekendday=>0,
:symbol=>"MSFT", :instrumenttype=>"S", :openprice=>23.25,
:highprice=>23.7199993133545, :lowprice=>23.25,
:closeprice=>23.6499996185303, :volume=>41822000, :openinterest=>0}

which looks like I should be able to test for r[:weekendday] == 0

I played with it some more, and if I omit the call to the stored proc, and
just use a sql select, e.g.,

dataset = DB[:masterdates].left_outer_join(:pricedata, :pricedate =>
:pricedate, :symbol => 'MSFT', :instrumenttype =>
'S').filter('(masterdates.pricedate > ?) and (masterdates.pricedate < ?)',
'2000-01-01', '2009-10-01')

it works as expected, i.e., I can successfully test for r[:weekendday] == 0.

The problem seems to be the fact that the initial retrieval is via a stored
proc...?


On Fri, Sep 25, 2009 at 12:51 PM, Jeremy Evans <[email protected]>wrote:

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