1

I'm woking on Python cx_Oracle INSERT INTO and I'm having an error which I can't find

My code can successfully connect to Oracle server

My code is

curs = connect.cursor()
number1 = input("Input number = ")
name = input("Input name = ")
address = input("Input address")
date = input("Input date in DD-MON-YYYY format = ")
number2 = input("Input number = ")
statement = "INSERT INTO table (:number1,:name,:address,:date,:number2) VALUES (:x,:n,:a,to_date(:d, 'DD-MON-YYYY'),:y)"
curs.execute(statement,{'x':number1, 'n':name, 'a':address, 'd':date, 'y':number2})
curs.commit()

I have tried my inputs with

1234, John, Elm Street,01-JAN-2000, 5678

The error said

cx_Oracle.DatabaseError: ORA-00928: missing SELECT keyword

I'm guessing the error is probably from the date format but I can't quite find where the exact error lies in my code

Could someone please point out what I'm doing wrong?

1
  • Will you please give full traceback? Commented Nov 13, 2014 at 5:26

1 Answer 1

2

'table' is a reserved word, so I'm not sure you can use as an actual table to query.

In your statement :number1 should be number1, :name should be name and so on.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.