tags:

views:

70

answers:

5

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

A: 

Have you tried this?

$marca = date('dd-mmm-yyyy H:i:s'); 
Madhivanan
Uh.. have you? "1515-060606-10101010 16:48:05"
MSpreij
give me the same error
Erick
@MSpreij: i don't undestand XD
Erick
@Erick: see http://php.net/date , the format input takes a single character per value, so 'Y' becomes '2010'. 'yyyy' becomes 10101010.
MSpreij
A: 

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')
        ";
Jacob Relkin
return: Call to undefined function CURRENT_TIMESTAMP()
Erick
Sorry. Strip out the parens and it should work
Jacob Relkin
thank it works correctly
Erick
A: 

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.

Gary
A: 

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

Silver Light
A: 

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

MSpreij