Reputation: 2049
I'm using oracle express and in my application i would insert a time-stamp value in my table:
$marca = date('y-m-d H:i:s');
$query = " INSERT INTO SA_VERSIONE
( ID_ACCETTAZIONE, MARCA_TEMPORALE, TESTO, FIRMA, MEDICO)
VALUES
('$id', '$marca', '$testo', '$firma', '$medico')
";
$stid = oci_parse($conn, $query);
oci_execute($stid);
but when execute it return:
Warning: oci_execute() [function.oci-execute]: ORA-01843: mese non valido in ... and say that the month is not valid
Upvotes: 1
Views: 2721
Reputation: 45902
Try using SYSDATE
instead of generating time by PHP
<?php
$query = " INSERT INTO SA_VERSIONE
( ID_ACCETTAZIONE, MARCA_TEMPORALE, TESTO, FIRMA, MEDICO)
VALUES
('$id', SYSDATE, '$testo', '$firma', '$medico')
";
$stid = oci_parse($conn, $query);
oci_execute($stid);
?>
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions172.htm
Upvotes: 0
Reputation: 163228
current_timestamp
should work for you.
If MARCA
isn't already a TIMESTAMP field, i suggest you make it one.
$query = " INSERT INTO SA_VERSIONE
( ID_ACCETTAZIONE, MARCA_TEMPORALE, TESTO, FIRMA, MEDICO)
VALUES
('$id', current_timestamp, '$testo', '$firma', '$medico')
";
Upvotes: 1
Reputation: 1152
Looks like Oracle expects a slightly different format, '10-JUN-15' - try date('y-M-d H:i:s'). If the time is not valid in there, check the url for more ideas :-)
http://infolab.stanford.edu/~ullman/fcdb/oracle/or-time.html
Upvotes: 0
Reputation: 2916
You can try:
INSERT INTO SA_VERSIONE
( ID_ACCETTAZIONE, MARCA_TEMPORALE, TESTO, FIRMA, MEDICO)
VALUES
('$id', '$marca', '$testo', '$firma', to_date($marca, 'yyyy/mm/dd hh:mi:ss));
Look into the to_date format options. They must match what you are inserting to what Oracle expects.
Upvotes: 0