ORA-01858: a non-numeric character was found where a numeric was expected

Hi Experts,

When i execute this statement i got an error called ORA-01858

mobile_number = ‘1234567890’
email = “[email protected]
secret_question = “whats your name”
secret_answer = “crystal”
date_of_birth = “20-SEP-90”

User.find(:first, :conditions => “mobile_number=’#{mobile_number}’ and
email=’#{email}’ and date_of_birth=’#{date_of_birth}’ and
secret_question=’#{secret_question}’ and
secret_answer=’#{secret_answer}’”)

ORA-01858: a non-numeric character was found where a numeric was
expected

but when i execute as query in BE its working well, anyhow, i’ve tried
using to_date(’#{date_of_birth}’, ‘dd-mon-yy’) the query executes well
with none record return, but i’ve the value of “20-SEP-90” on my db

anyway, i’ve a model Users with date_of_birth column with the type
of :date

any suggestions?

is there any difference between rails date and oracle date?

thanks in advance Experts

waiting for the reply,

regards,

Bala

Hi, Bala

You have to use Class Date to wrap the your date_of_birth string, Try
following:

date_of_birth=Date.new(1990,9,20)

And execute your query statement again to see if it can get correct
result.

Regards,
Liming

Hi Liming,

Thanks for the reply.

I’ve tried like you suggest, i dont get ORA error, but the record
fetch none.
still its says empty

Regards,

Bala

Hi Liming,

Thanks for the reply.

I’ve tried like you suggest, i dont get ORA error, but the record
fetch none.
still its says empty

Regards,

Bala

Oh My Bad, so Sorry Liming,

got it, i’ve typed wrong date.

it works perfectly.

Thanks a lot.

regards,

Bala

A little bit strange, how about only using date_of_birth condition
like following?

User.find(:first, :conditions => "date_of_birth=’#{date_of_birth}’ ")

I just guess that maybe some other field doesn’t match.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs