Ok, first things first: I'm an idiot, sorry for the waste of time.
Second, the problem was a typo. I cleaned up the code that I had posted
here, but not the code that I was running. Here's what I was running:
dataset.map do |r|
if (r[:weekend] == 0) # oops... :(
out_str = "***" + r[:weekendday].to_s + "***"
puts out_str
end
end
If you try it, you'll see it does what I originally described.
I'm a windows programmer, and the equivalent of this (in, say, Delphi) would
have given me a runtime error, it seems to me. That would have been helpful
here, but I'm a stranger here so maybe this is the way Ruby/interpreted
languages are.
Anyway, again, thanks for the support everybody.
On Fri, Sep 25, 2009 at 4:46 PM, David Jenkins <[email protected]>wrote:
> As far as I can tell, all the findings up to this point support that
> outcome. And yet...
>
>
> On Fri, Sep 25, 2009 at 4:35 PM, Aman Gupta <[email protected]>wrote:
>
>>
>> Both of these work fine for me:
>>
>>
>> Marshal.load("\x04\b{\x10:\x0Epricedateu:\tTime\r\x04^\e\x80\x00\x00\x00\x00:\fholidayi\x00:\x0Fweekenddayi\x06:\vsymbol0:\x13instrumenttype0:\x0Eopenprice0:\x0Ehighprice0:\rlowprice0:\x0Fcloseprice0:\vvolume0:\x11openinterest0")[:weekendday]
>> == 1
>> => true
>>
>>
>> Marshal.load("\x04\b{\x11:\x0Epricedate0:\fholidayi\x00:\x0Fweekenddayi\x06:\rexchange0:\vsymbol0:\x13instrumenttype0:\x0Eopenprice0:\x0Ehighprice0:\rlowprice0:\x0Fcloseprice0:\vvolume0:\x11openinterest0")[:weekendday]
>> == 1
>> => true
>>
>>
>> On Fri, Sep 25, 2009 at 12:46 PM, David Jenkins <[email protected]>
>> wrote:
>> >>Perhaps you can post the results of p(Marshal.dump(r)) for both cases:
>> >>with the select, and with the stored procedure.
>> > Here are the outputs (p(Marshal.dump(r)) of the last 4 recs from the
>> stored
>> > proc:
>> >
>> "\x04\b{\x10:\x0Epricedateu:\tTime\r\x04^\e\x80\x00\x00\x00\x00:\fholidayi\x00:\x0Fweekenddayi\x06:\vsymbol0:\x13instrumenttype0:\x0Eopenprice0:\x0Ehighprice0:\rlowprice0:\x0Fcloseprice0:\vvolume0:\x11openinterest0"
>> >
>> "\x04\b{\x10:\x0Epricedateu:\tTime\r$^\e\x80\x00\x00\x00\x00:\fholidayi\x00:\x0Fweekenddayi\x00:\vsymbol\"\tMSFT:\x13instrumenttype\"\x06S:\x0Eopenpricef\x1A23.319999694824201\x00\xFF\xFB:\x0Ehighpricef\x1A23.600000381469702\x00\xFF\xF9:\rlowpricef\x1823.2299995422363\x00\xFF\xF8:\x0Fclosepricef\n23.25:\vvolumei\x04\xD8\x1A\x88\x02:\x11openinteresti\x00"
>> >
>> "\x04\b{\x10:\x0Epricedateu:\tTime\rD^\e\x80\x00\x00\x00\x00:\fholidayi\x00:\x0Fweekenddayi\x00:\vsymbol\"\tMSFT:\x13instrumenttype\"\x06S:\x0Eopenpricef\x1A23.290000915527301\x00\xFF\xF4:\x0Ehighpricef\x1A23.649999618530298\x00\x00\a:\rlowpricef\x1823.2700004577637\x00\x00\b:\x0Fclosepricef\x1A23.579999923706101\x00\x00\r:\vvolumei\x04P%Q\x02:\x11openinteresti\x00"
>> >
>> "\x04\b{\x10:\x0Epricedateu:\tTime\rd^\e\x80\x00\x00\x00\x00:\fholidayi\x00:\x0Fweekenddayi\x00:\vsymbol\"\tMSFT:\x13instrumenttype\"\x06S:\x0Eopenpricef\n23.25:\x0Ehighpricef\x1A23.719999313354499\x00\x00\x02:\rlowpricef\n23.25:\x0Fclosepricef\x1A23.649999618530298\x00\x00\a:\vvolumei\x040'~\x02:\x11openinteresti\x00"
>> >
>> > and here are the last 4 from the select
>> >
>> "\x04\b{\x11:\x0Epricedate0:\fholidayi\x00:\x0Fweekenddayi\x06:\rexchange0:\vsymbol0:\x13instrumenttype0:\x0Eopenprice0:\x0Ehighprice0:\rlowprice0:\x0Fcloseprice0:\vvolume0:\x11openinterest0"
>> >
>> "\x04\b{\x11:\x0Epricedate0:\fholidayi\x00:\x0Fweekenddayi\x06:\rexchange0:\vsymbol0:\x13instrumenttype0:\x0Eopenprice0:\x0Ehighprice0:\rlowprice0:\x0Fcloseprice0:\vvolume0:\x11openinterest0"
>> >
>> "\x04\b{\x11:\x0Epricedateu:\tTime\r$^\e\x80\x00\x00\x00\x00:\fholidayi\x00:\x0Fweekenddayi\x00:\rexchange\"\tNASD:\vsymbol\"\tMSFT:\x13instrumenttype\"\x06S:\x0Eopenpricef\x1A23.319999694824201\x00\xFF\xFB:\x0Ehighpricef\x1A23.600000381469702\x00\xFF\xF9:\rlowpricef\x1823.2299995422363\x00\xFF\xF8:\x0Fclosepricef\n23.25:\vvolumei\x04\xD8\x1A\x88\x02:\x11openinteresti\x00"
>> >
>> "\x04\b{\x11:\x0Epricedateu:\tTime\rD^\e\x80\x00\x00\x00\x00:\fholidayi\x00:\x0Fweekenddayi\x00:\rexchange\"\tNASD:\vsymbol\"\tMSFT:\x13instrumenttype\"\x06S:\x0Eopenpricef\x1A23.290000915527301\x00\xFF\xF4:\x0Ehighpricef\x1A23.649999618530298\x00\x00\a:\rlowpricef\x1823.2700004577637\x00\x00\b:\x0Fclosepricef\x1A23.579999923706101\x00\x00\r:\vvolumei\x04P%Q\x02:\x11openinteresti\x00"
>> >
>> > here's the stored proc:
>> > CREATE definer=`ro...@`localhost` PROCEDURE `GetInstRecs`(SYM
>> varchar(28),
>> > INSTTYPE varchar(2))
>> > BEGIN
>> > declare FROMDATE date;
>> > declare TODATE date;
>> > call GetMinMaxDates(SYM,INSTTYPE, FROMDATE,TODATE );
>> > SELECT m.pricedate , m.holiday, m.weekendday, p.symbol,
>> p.instrumenttype,
>> > p.openprice,
>> > p.highprice, p.lowprice, p.closeprice, p.volume, p.openinterest
>> > FROM masterdates m left join pricedata p
>> > on m.pricedate = p.pricedate and p.symbol = SYM and p.instrumenttype =
>> > INSTTYPE
>> > where m.pricedate >= FROMDATE and m.pricedate <= TODATE;
>> > END
>> > and here's how I call it:
>> >
>> > dataset = DB['call GetInstRecs(\'MSFT\', \'S\')']
>> >
>> >
>> > and here's the sequel select version
>> >
>> > dataset = DB[:masterdates].left_outer_join(:pricedata, :pricedate =>
>> > :pricedate, :symbol => 'MSFT', :instrumenttype =>
>> > 'S').filter('(masterdates.pricedate > ?) and (masterdates.pricedate <
>> ?)',
>> > '2000-01-01', '2009-08-19')
>> >
>> > On Fri, Sep 25, 2009 at 3:27 PM, Aman Gupta <[email protected]>
>> > wrote:
>> >>
>> >> Perhaps you can post the results of p(Marshal.dump(r)) for both cases:
>> >> with the select, and with the stored procedure.
>> >>
>> >> Aman
>> >>
>> >> On Fri, Sep 25, 2009 at 12:19 PM, David Jenkins <[email protected]
>> >
>> >> wrote:
>> >> > Hi, John
>> >> >
>> >> > Thanks for the suggestions. Using :holiday does the same thing,
>> i.e., I
>> >> > can't use it in an "if" test. I also tried setting a variable,
>> >> > "some_var"
>> >> > to r[:weekendday], and sure enough it gets set to 0 or 1, and its
>> class
>> >> > is
>> >> > Fixnum.
>> >> >
>> >> > Again, since this works with a select statement and not when I use a
>> >> > stored
>> >> > proc that returns a dataset, it seems to be a problem with the
>> latter.
>> >> > I'm
>> >> > am trying to debug the sequel code in NetBeans 6.7, but I'm getting
>> >> > weird
>> >> > results: it keeps stopping on comment lines, as if the file it's
>> showing
>> >> > is
>> >> > not the file it's running (and the file its actually running has
>> actual
>> >> > non-comment code on those lines) -- the file in question being
>> mysql.rb.
>> >> >
>> >> >
>> >> >
>> >> > On Fri, Sep 25, 2009 at 3:10 PM, John W Higgins <[email protected]>
>> >> > wrote:
>> >> >>
>> >> >>
>> >> >> On Fri, Sep 25, 2009 at 11:49 AM, David Jenkins <
>> [email protected]>
>> >> >> wrote:
>> >> >>>
>> >> >>> tried p r[:weekendday].class, all Fixnum
>> >> >>> :(
>> >> >>
>> >> >> Try using :holiday instead - looks like the same semantics in terms
>> of
>> >> >> data type but it might help figure out if it's a field issue or
>> >> >> something
>> >> >> else.
>> >> >>
>> >> >> Also try setting another variable with the value and then testing
>> that
>> >> >> to
>> >> >> see if there is something else funky going on with the local
>> >> >> representation.
>> >> >> I would say at this point you're down to documenting every stage and
>> >> >> seeing
>> >> >> where this goes off track.
>> >> >>
>> >> >> Most times these types of things are nothing more then some weird
>> >> >> anomaly
>> >> >> but if you poke and prod around the issue sometimes you get the
>> right
>> >> >> clue.
>> >> >>
>> >> >> Sorry I don't have a silver bullet - but sometimes the bullet
>> companies
>> >> >> are on strike :)
>> >> >>
>> >> >> John
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> > >
>> >> >
>> >>
>> >>
>> >
>> >
>> > >
>> >
>>
>> >>
>>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---