There is a problem with Oracle ORA-00917: missing comma (pandas python

Viewed 21

I am trying to put pandas table like this into my Oracle Database. My pandas table looks like this

enter image description here

this is my script to insert the data

INSERT INTO DATA 
(NO_TRANSMITTER,ZONA,STATUS_PELABUHAN,TO_DATE(REPORTDATE,'YYYY-MM-DD HH24:MI:SS'),STATUS)
VALUES(:1,:2,:3,:4,:5)

It gets result like this

There is a problem with Oracle ORA-00917: missing comma

I don't know where comma needed to. Thanks for the help.

1 Answers

Put TO_DATE into the VALUES clause and not into the column identifier list:

INSERT INTO DATA (
  NO_TRANSMITTER,
  ZONA,
  STATUS_PELABUHAN,
  REPORTDATE,
  STATUS
) VALUES (
  :1,
  :2,
  TO_DATE(:3,'YYYY-MM-DD HH24:MI:SS'),
  :4,
  :5
)

Or, if the value in Pandas, is already stored as a datetime (and not a string) then simplify it to:

INSERT INTO DATA (
  NO_TRANSMITTER,
  ZONA,
  STATUS_PELABUHAN,
  REPORTDATE,
  STATUS
) VALUES (
  :1,
  :2,
  :3,
  :4,
  :5
)
Related