NYCPHP Meetup

NYPHP.org

[nycphp-talk] PEAR Prepare and Oracle to_date

Eric Gewirtz egewirtz at rcn.com
Fri Feb 11 23:05:15 EST 2005


I found the solution. Daniel thanks again for pointing me to the
getDebugInfo().

I did some hunting on the web for the ora-01841 error message I was
getting and found the following information;

Jon, it looks like you are wanting to use to_date with two parameters
but you are only giving it one bind variable (which,taken together, will
be something Oracle won't know to convert into a date). Oracle is trying
to take your single bind variable interpret it as a date using the
default date format for your Oracle session (which is probably
YYYY-MM-DD already). Give two bind variables a try, and it should work. 
-- Michael A. Cleverly, March 21, 2001

This was exactly what I was doing - I was only giving to_date one
parameter and hard coding the date mask - now my insert sql to be
compiled by the prepare looks like this (THIS IS CORRECT):

"INSERT INTO TESTERIC (FNAME,LNAME,AGE,BDATE) VALUES
(?,?,?,to_date(?,?))"; 
vs
THIS IS WRONG
"INSERT INTO TESTERIC (FNAME,LNAME,AGE,BDATE) VALUES
(?,?,?,to_date(?,'".DATE_MASK_ORA."'))";

Eric

Eric Gewirtz
SolutionOne
Phone - 845-729-7800
Fax     - 845-279-5502
egewirtz at rcn.com
 

>-----Original Message-----
>From: talk-bounces at lists.nyphp.org
[mailto:talk-bounces at lists.nyphp.org] On
>Behalf Of Daniel Convissor
>Sent: Friday, February 11, 2005 6:00 PM
>To: NYPHP Talk
>Subject: Re: [nycphp-talk] PEAR Prepare and Oracle to_date
>
>Hi Eric:
>
>On Fri, Feb 11, 2005 at 05:24:51PM -0500, Eric Gewirtz wrote:
>... snip ...
>
>Wow.  That's a long example.  In the future, may I suggest simplifying
>things?  Makes it easier for us, let alone you, to figure out what's
going
>on.
>
>You're using the wrong object to get the error message.  Second, use
the
>getDebugInfo() method instead because it shows the native error message
>from the DBMS.
>
>> $result = $db->execute($compiled, $arrData);
>> if (DB::isError($result)) {
>>             echo "EXECUTE FAILED \n";
>>             die($db->getMessage());
>
>So, make that last line:
>
>              die($result->getDebugInfo());
>
>Now you should be able to figure out what's going on for yourself from
the
>error message.
>
>--Dan
>
>PS:  Take a look at http://www.expita.com/nomime.html.
>
>--
> T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
>            data intensive web and database programming
>                http://www.AnalysisAndSolutions.com/
> 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409
>_______________________________________________
>New York PHP Talk
>Supporting AMP Technology (Apache/MySQL/PHP)
>http://lists.nyphp.org/mailman/listinfo/talk
>http://www.nyphp.org




More information about the talk mailing list