0

I am running following command to fetch data of particular customer but output comes out to be null or no data found, while data is already stored in the table. Can anyone identify the problem

custid=input("Enter CustomerID:")  
cur.execute("""SELECT * FROM INFYCAMPUSCONNECT.CUSTOMER WHERE CUSTOMERID= :1 """ , (custid))
11
  • Just tried using %s. It give following error:cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number Commented Jun 13, 2018 at 19:29
  • 1
    We need more information. Which database backend are you using? Which module do you use to connect to it? What are you typing? What is the type of the column in the database? What results do you get? Edit the question and add full error traceback? Commented Jun 13, 2018 at 19:30
  • @nosklo The error message indicates that he's using Oracle. Commented Jun 13, 2018 at 19:34
  • @Barmar :1 is correct for some databases. Unfortunately there is no information in the question. Commented Jun 13, 2018 at 19:34
  • It has the oracle tag as well. Commented Jun 13, 2018 at 19:35

1 Answer 1

2

The parameters need to be a tuple, so you have to put a comma in the parentheses:

cur.execute("""SELECT * FROM INFYCAMPUSCONNECT.CUSTOMER WHERE CUSTOMERID= :1 """ , (custid,))
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.