Dave Britton
dave at davebritton.com
Tue Jan 10 07:32:52 EST 2006
Construct the sql query and print it out before you do the cursor.execute. Then you can see what is wrong with the query that causes it to fail in Oracle. eg: sql = "INSERT INTO PERSONALDETAILS (firstname,middlename,lastname) VALUES (%s, %s, %s)"%(fname,mname,lname) writeln(sql) # now you will see the bad SQL statement! Possibly you have no value for one of the cgi variables because of leaving the form field blank (such as no middle name), which will cause the function to fail because that variable will not exist. You must be sure you have default values set for your cgi variable in the function definition eg: def index(req, fname="", mname='"", lname="") so that all variables will exist and have valid string definitions even if the user does not enter anything into that field on the html form. Also, maybe you misspelled one of the form variable names in the html form. We cannot tell from this snippet. -Dave ----- Original Message ----- From: python eager To: mod_python at modpython.org Sent: Monday, January 09, 2006 8:01 AM Subject: [mod_python] error while inserting data Hi i m getting the following errors. Please solve this problem Hi this is my code snippet. req = self.request() fname = req.field('fname') mname = req.field('mname') lname = req.field('lname') dbconnection = cx_Oracle.connect("myuser", "mypassword", "mydatabase") cursor = dbconnection.cursor() cursor.arraysize = 50 self.writeln("hello") cursor.execute("INSERT INTO PERSONALDETAILS (firstname,middlename,lastname) VALUES (%s, %s, %s)", (fname,mname,lname)) dbconnection.commit() While executing i am getting the following error cursor.execute("INSERT INTO PERSONALDETAILS(firstname,middlename,lastname) VALUES (%s, %s, %s)", (fname,mname,lname)) DatabaseError: ORA-01036: illegal variable name/number please solve this problem. regards Python Eager ------------------------------------------------------------------------------ Yahoo! Photos Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever. ------------------------------------------------------------------------------ _______________________________________________ Mod_python mailing list Mod_python at modpython.org http://mailman.modpython.org/mailman/listinfo/mod_python -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20060110/30dd323a/attachment-0001.html
|