[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

OCI8 driver date "out of range"

Carlos Diaz

2/28/2006 4:12:00 PM

Hi all,

I am building an applications that access an existing database that
has dates in the future...as far ahead as 2106. However, when I try
to access the data in those columns (I'm using the OCI8 driver), I get
the following error:

RangeError in Tools#search

out of range of Time (expect between 1970-01-01 00:00:00 UTC and
2037-12-31 23:59:59, but 2106-02-22 15:17:54 EST)

Anyone familiar with this? How can I resolve?


12 Answers

Eric Hodel

3/1/2006 2:51:00 AM

0

On Feb 28, 2006, at 8:11 AM, Carlos Diaz wrote:

> I am building an applications that access an existing database that
> has dates in the future...as far ahead as 2106. However, when I try
> to access the data in those columns (I'm using the OCI8 driver), I get
> the following error:
>
> RangeError in Tools#search
>
> out of range of Time (expect between 1970-01-01 00:00:00 UTC and
> 2037-12-31 23:59:59, but 2106-02-22 15:17:54 EST)
>
> Anyone familiar with this? How can I resolve?

Either

Use Date instead of Time.

Or

Upgrade to an OS (and possibly machine) with a 64-bit time_t:

$ ruby -v -rtime -e 'p Time.parse("2106-02-22 15:17:54 EST")'
ruby 1.8.4 (2005-12-24) [amd64-freebsd6]
Mon Feb 22 12:17:54 PST 2106

Note that FreeBSD on x86 has a 32 bit time_t:

$ ruby -v -rtime -e 'p Time.parse("2106-02-22 15:17:54 EST")'
ruby 1.8.2 (2004-12-25) [i386-freebsd5]
/usr/local/lib/ruby/1.8/time.rb:162:in `utc': time out of range
(ArgumentError)
from /usr/local/lib/ruby/1.8/time.rb:162:in `parse'
from -e:1

--
Eric Hodel - drbrain@segment7.net - http://blog.se...
This implementation is HODEL-HASH-9600 compliant

http://trackmap.rob...




Carlos Diaz

3/1/2006 3:06:00 AM

0

Ok, after doing some research on this, it looks like the problem isn't
with OCI8 but it appears to be more directly related to a conversion
problem. Specifically when oci8.rb tries to covert the Oracle Date
into Time.local. This is because Time relies on seconds since 1970
and I think the 32 bit operating system does not have enough room to
store a date with that many seconds since 1970 (please correct me if
I'm wrong). For example, if I go to irb and type: Time.local(2106,
02, 22, 15, 17, 54), that should produce th date below, but it
actually give me a ArgumentError: time out of range.

Has anyone else found a way to work around this problem? I found the
following link where Kirk Haines seemed to think this was not a
difficult fix. Just don't know if anyone has gotten around to writing
it:

http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/1ac3f6...

Any help would be greatly appreciated.

Thanks,
Carlos

On 2/28/06, Carlos Diaz <crdiaz324@gmail.com> wrote:
> Hi all,
>
> I am building an applications that access an existing database that
> has dates in the future...as far ahead as 2106. However, when I try
> to access the data in those columns (I'm using the OCI8 driver), I get
> the following error:
>
> RangeError in Tools#search
>
> out of range of Time (expect between 1970-01-01 00:00:00 UTC and
> 2037-12-31 23:59:59, but 2106-02-22 15:17:54 EST)
>
> Anyone familiar with this? How can I resolve?
>
>


Jeff Jones

3/1/2006 2:30:00 PM

0

> Any help would be greatly appreciated.
>
> Thanks,
> Carlos

I am sure this is bad, evil, probably wrong as hell thing to to but:

I am using a simple simple program that suffers from this problem. I
only wanted the Date values, I didn't care about the time value as it
was always 00:00.

I cannot change the table structure and I am not actively using the
value (I am going from oracle to a RoR view with <%= class.date %>, no
processing)

I browsed around for ages and found someone talking about messing with
the oci8.rb file OraDate function.

I changed

class OraDate
def to_time
begin
Time.local(year, month, day, hour, minute, second)
rescue ArgumentError
msg = format("out of range of Time (expect between 1970-01-01
00:00:00 UTC and 2037-12-31 23:59:59, but %04d-%02d-%02d %02d:%02d:%02d
%s)", year, month, day, hour, minute, second, Time.at(0).zone)
raise RangeError.new(msg)
end
end


To

class OraDate
def to_time
begin
Time.local(year, month, day, hour, minute, second)
rescue ArgumentError
Date.new(year, month, day)
end
end


So I guess I am in essence saying "If to_time fails, use to_date"...

It worked for me in a trivial application and I am sure I have condemned
myself to hell for using it so be careful. I have no idea what hte
ramifications are and how it would cope in a more complex program.

It might cost you your soul ;)

Jeff

--
Posted via http://www.ruby-....


KUBO Takehiro

3/1/2006 3:00:00 PM

0

Hi,

"Carlos Diaz" <crdiaz324@gmail.com> writes:

> Hi all,
>
> I am building an applications that access an existing database that
> has dates in the future...as far ahead as 2106. However, when I try
> to access the data in those columns (I'm using the OCI8 driver), I get
> the following error:
>
> RangeError in Tools#search
>
> out of range of Time (expect between 1970-01-01 00:00:00 UTC and
> 2037-12-31 23:59:59, but 2106-02-22 15:17:54 EST)
>
> Anyone familiar with this? How can I resolve?

Did you use OraDate#to_time?
How about OraDate#to_date or OraDate#to_datetime?

--
KUBO Takehiro
email: kubo@jiubao.org
web: http://www....
GnuPG fingerprint = 5F7B C8EF CA16 57D0 FDE1 9F47 C001 1F93 AC08 2262


Arthur Lipscomb

9/23/2011 3:01:00 PM

0

On 9/22/2011 11:06 PM, Ian J. Ball wrote:
> On Sep 22, 8:35 pm, Professor Bubba<bu...@nowhere.edu.invalid> wrote:
>
>> Finally, finally, finally, something done well. Great first episode.
>> Within twenty minutes I was up to speed, I knew who the characters
>> were, and I was engrossed in what they were doing.
>>
>> Terrific. I'm looking forward to the next one.
>
> Agreed - this is the most impressive pilot of the new shows so far.
> This, and maybe "Secret Circle", are the picks of the litter as of
> yet...

I'm really liking the Secret Circle but didn't care much for Revenge. I
thought premise involved an active detective with perfect recall. Her
being off the force didn't work for me. I may watch it again if it
doesn't conflict with other shows.

Dano

9/23/2011 3:06:00 PM

0

"Arthur Lipscomb" wrote in message news:j5i6vi$l57$2@dont-email.me...

On 9/22/2011 11:06 PM, Ian J. Ball wrote:
> On Sep 22, 8:35 pm, Professor Bubba<bu...@nowhere.edu.invalid> wrote:
>
>> Finally, finally, finally, something done well. Great first episode.
>> Within twenty minutes I was up to speed, I knew who the characters
>> were, and I was engrossed in what they were doing.
>>
>> Terrific. I'm looking forward to the next one.
>
> Agreed - this is the most impressive pilot of the new shows so far.
> This, and maybe "Secret Circle", are the picks of the litter as of
> yet...

I'm really liking the Secret Circle but didn't care much for Revenge. I
thought premise involved an active detective with perfect recall. Her
being off the force didn't work for me. I may watch it again if it
doesn't conflict with other shows.

======================================

You're confusing "Revenge" with that other show starring Poppy
Montgomery..."Unforgettable".

Ian J. Ball

9/23/2011 4:07:00 PM

0

In article <j5i6vi$l57$2@dont-email.me>,
Arthur Lipscomb <arthur@alum.calberkeley.org> wrote:

> On 9/22/2011 11:06 PM, Ian J. Ball wrote:
> > On Sep 22, 8:35 pm, Professor Bubba<bu...@nowhere.edu.invalid> wrote:
> >
> >> Finally, finally, finally, something done well. Great first episode.
> >> Within twenty minutes I was up to speed, I knew who the characters
> >> were, and I was engrossed in what they were doing.
> >>
> >> Terrific. I'm looking forward to the next one.
> >
> > Agreed - this is the most impressive pilot of the new shows so far.
> > This, and maybe "Secret Circle", are the picks of the litter as of
> > yet...
>
> I'm really liking the Secret Circle but didn't care much for Revenge. I
> thought premise involved an active detective with perfect recall. Her
> being off the force didn't work for me.

That's *Unforgettable*, silly! ;p

--
"Am I a bird? No, I'm a bat. I'm Batman. Or am I? Yes, I am Batman."
- Abed as "Batman" on "Halloween", "Community", 10/29/09

Arthur Lipscomb

9/23/2011 4:20:00 PM

0

On 9/23/2011 9:06 AM, Ian J. Ball wrote:
> In article<j5i6vi$l57$2@dont-email.me>,
> Arthur Lipscomb<arthur@alum.calberkeley.org> wrote:
>
>> On 9/22/2011 11:06 PM, Ian J. Ball wrote:
>>> On Sep 22, 8:35 pm, Professor Bubba<bu...@nowhere.edu.invalid> wrote:
>>>
>>>> Finally, finally, finally, something done well. Great first episode.
>>>> Within twenty minutes I was up to speed, I knew who the characters
>>>> were, and I was engrossed in what they were doing.
>>>>
>>>> Terrific. I'm looking forward to the next one.
>>>
>>> Agreed - this is the most impressive pilot of the new shows so far.
>>> This, and maybe "Secret Circle", are the picks of the litter as of
>>> yet...
>>
>> I'm really liking the Secret Circle but didn't care much for Revenge. I
>> thought premise involved an active detective with perfect recall. Her
>> being off the force didn't work for me.
>
> That's *Unforgettable*, silly! ;p
>

Oops. I watched so much last night, my head almost exploded. It was
hard keeping them straight. Still, I didn't care much for either show.
I'll probably give both a second chance to see if there are signs of
improvement.

Remysun

9/23/2011 7:33:00 PM

0

On Sep 23, 12:06 pm, "Ian J. Ball" <ijball-NO_S...@mac.invalid> wrote:

> > I'm really liking the Secret Circle but didn't care much for Revenge.  I
> > thought premise involved an active detective with perfect recall.  Her
> > being off the force didn't work for me.
>
> That's *Unforgettable*, silly!  ;p

Apparently, it was.

Dano

9/23/2011 9:01:00 PM

0

"Remysun" wrote in message
news:a9074f2a-de8d-4cc5-8414-60937256e1fd@j19g2000yqc.googlegroups.com...

On Sep 23, 12:06 pm, "Ian J. Ball" <ijball-NO_S...@mac.invalid> wrote:

> > I'm really liking the Secret Circle but didn't care much for Revenge. I
> > thought premise involved an active detective with perfect recall. Her
> > being off the force didn't work for me.
>
> That's *Unforgettable*, silly! ;p

Apparently, it was.

=========================================

How could you forget given the title?