odbc errors

E

eight02645999

hi

i have a piece of code:
....

def connectdb(sql):
import dbi
import odbc
import sys
try:
s = odbc.odbc('DSN=CONN;UID=user;PWD=pass')
cur = s.cursor()
# cur.execute("set nocount on")
cur.execute(sql)
while 1:
rec = cur.fetchone()
if not rec: break
return rec
except:
print 'error while processing ', sys.exc_type,sys.exc_value
s.close()
cur.close()
s = None
cur = None

....
sql = r'update table set col = 'A' where user = "user1"'
connectdb(sql)


when i execute it from CGI, i encounter the following :
error while processing dbi.internal-error [MERANT][ODBC Sybase ASE
driver]Invalid cursor state. in FETCH None

but when i did check the table, the value of col is updated to 'A',
how can i suppress the above error message? or is there some other
things
that are wrong with the code.
thanks
 
R

Roger Upole

hi

i have a piece of code:
...

def connectdb(sql):
import dbi
import odbc
import sys
try:
s = odbc.odbc('DSN=CONN;UID=user;PWD=pass')
cur = s.cursor()
# cur.execute("set nocount on")
cur.execute(sql)
while 1:
rec = cur.fetchone()
if not rec: break
return rec
except:
print 'error while processing ', sys.exc_type,sys.exc_value
s.close()
cur.close()
s = None
cur = None

...
sql = r'update table set col = 'A' where user = "user1"'
connectdb(sql)


when i execute it from CGI, i encounter the following :
error while processing dbi.internal-error [MERANT][ODBC Sybase ASE
driver]Invalid cursor state. in FETCH None

but when i did check the table, the value of col is updated to 'A',
how can i suppress the above error message? or is there some other
things
that are wrong with the code.
thanks

The update is performed as soon as you execute the cursor.
No recordset is returned from the update, so you can remove
the fetch altogether.

hth
Roger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top