RE: [cx-oracle-users] trouble with insert
Brought to you by:
atuining
From: Guido v. R. <gu...@el...> - 2005-04-14 20:02:54
|
I think the problem is this bit of SQL: =20 VALUES (:content_id, ':vizstylename', ':themedesc', ':themename', ':vizstylename', 0) =20 Note how you put 'single quotes' around some of the variable names. Try without those. =20 =20 =20 --Guido van Rossum (home page: http://www.python.org/~guido) =20 ________________________________ From: cx-...@li... [mailto:cx-...@li...] On Behalf Of Andrew Replogle Sent: Thursday, April 14, 2005 12:54 PM To: cx-...@li... Subject: [cx-oracle-users] trouble with insert =09 =09 =09 --- #!/usr/bin/python =20 import sys import cx_Oracle =20 =20 dbinst =3D sys.argv [1] dbuser =3D sys.argv[2] dbpass =3D sys.argv[3] =20 try: myconn =3D cx_Oracle.connect(dbuser,dbpass,dbinst) except cx_Oracle.DatabaseError, x: =20 print "" print "Unable to connect to Database." print x =20 =20 =20 cursor =3D myconn.cursor() cursor.arraysize =3D 50 cursor.execute(""" SELECT content_style_id_seq.nextval FROM dual" "") =20 =20 def add_theme(): for content_style_id in cursor.fetchall(): nextval =3D str(content_style_id[0]) =09 cursor.execute(""" INSERT INTO CONTENT_STYLE (CONTENT_STYLE_ID, NAME, DESCRIPTION, THEME, CLIENT, DELETED) VALUES (:content_id, ':vizstylename', ':themedesc', ':themename', ':vizstylename', 0)" "", content_id =3D nextval, themename =3D sys.argv[4], vizstylename =3D sys.argv[5], themedesc =3D sys.argv[6]) myResults =3D cursor.fetchall() =20 if cursor.rowcount =3D=3D 0: print "The theme could not be added for an unknown reason." else: =09 cursor.execute("""COMMIT""") print=20 "Theme ",sys.argv[4],"added with content style",sys.argv[5],"and description",sys.argv[6] =20 =20 add_theme() --- =09 =09 andrewr@zepher:~/bin$ ./add_theme.py PSG MGMTUSER01 MGMTUSER01 prenhalltheme prenhall PrenticeHall Traceback (most recent call last): File "./add_theme.py", line 42, in ? add_theme() File "./add_theme.py", line 33, in add_theme =09 content_id =3D nextval, themename =3D sys.argv[4], vizstylename =3D sys.argv[5], themedesc =3D sys.argv[6]) cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number --- =09 I have no idea what the illegal variable name / number is.. I've read issues where the variable is 32 char or longer or if a :=20 =09 missing in front of the variable assignment .. but none of these apply here.. can anyone tell me what I'm doing wrong? =09 TIA, =09 Andrew Replogle =09 |