Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: insert record of type date

Re: insert record of type date

From: TurkBear <noone_at_nowhere.com>
Date: Wed, 25 Apr 2001 12:45:23 -0500
Message-ID: <uu2eetce9rcpekq5bs2tmaqs3fnapilqil@4ax.com>

To use the format you are supplying to the date field you need to use the To_Date function and a format mask..

Try
$stmt = OCIParse($conn,"insert into coxyyyzzzaaaa.test (dateoffbirth) values (to_date('<?php echo $Day;?>-<?php echo $Month;?>-<?php echo $Year;?>'),'DD-MON-YYYY')");

I'm not sure because of the various 'quotes' and " s that are needed, but something like that should work...Or, prior to constructing your select statement, you could pre-format the input to something like "01-jan-1999" and use that in the to_date statement with the format mask set to whatever is needed..

"Gerry Stijlemans" <gerry.stijlemans_at_pandora.be> wrote:

><HTML><HEAD></HEAD><BODY>
><form name='Date' action='testdate.php' Method='Post'>
><select name='Day' size=1>
><option value='1'>01</option>...........<option value='31'>31</option>
></select>
><select name='Month' size=1>
><option value='jan'>Januari</option>.......<option
>value='dec'>December</option>
></select>
><select name='Year' size=1>
><option value='1900'>1900</option>.............<option
>value='2001'>2001</option>
></select>
><input type='submit' value='Submit'>
></form></BODY></HTML>
>
>This is the Testdate.php
><HTML><HEAD></HEAD><BODY>
>insert into coxyyyzzzaaaa.test (dateoffbirth) values ('<?php echo
>$Day;?>-<?php echo $Month;?>-<?php echo $Year;?>')
><?php $conn = OCILogon("coxyyyzzzaaaa", "admin" , "companyx");
>$stmt = OCIParse($conn,"insert into coxyyyzzzaaaa.test (dateoffbirth) values
>('<?php echo $Day;?>-<?php echo $Month;?>-<?php echo $Year;?>')");
>OCIExecute($stmt);OCICommit($conn);OCIFreeStatement($stmt);OCILogoff($conn);
>?>
></BODY></HTML>
>
>OUTPUT I RECIEVED :
>insert into coxyyyzzzaaaa.test (dateoffbirth) values ('1-jan-1900')
>Warning: OCIStmtExecute: ORA-01858: a non-numeric character was found where
>a numeric was expected in c:\program
>files\apache group\apache\htdocs\examples\project\testdate.php on line 9
>
>However the insert generated as above is working is sqlplus, I 'm recieving
>the
>above error. If I 'm reading this message as wel , I think the system is
>handling the $Day ,$Month and $Year as text and not as number.
>How can I correct this whole thing ?????
>
>THX
>
>Gerry
>
Received on Wed Apr 25 2001 - 12:45:23 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US