I have an Oracle database and need to insert a string with a date in YYYY-MM-DD HH:MM:SS format into an Oracle timestamp field. For this I have written this code:
$date = '2013-01-01 10:10:10';
$sql = oci_parse($c,"INSERT INTO MY_TABLE (ID, SEND_DATE) VALUES (MY_SEQ.nextval, TO_TIMESTAMP(:send_date, 'YYYY-MM-DD HH24:MI:SS'))");
oci_bind_by_name($sql, ':send_date', $date, null, SQLT_CHR);
oci_execute($sql);
The table looks like this:
CREATE TABLE "MY_TABLE"
( "ID" NUMBER NOT NULL ENABLE,
"SEND_DATE" TIMESTAMP (0) NOT NULL ENABLE );
If I execute the query above, I get this error:
ORA-01461: can bind a LONG value only for insert into a LONG column
There are already tons of questions regarding ORA-01461 on Stack Overflow, yet I could not find a solution for this particular problem. I really cannot understand where in this constellation LONG comes in.