471,046 Members | 1,270 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,046 software developers and data experts.

odbc errors

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

Oct 16 '05 #1
1 2821
ei***********@yahoo.com wrote:
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

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Oct 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Steve | last post: by
3 posts views Thread by Jason Gyetko | last post: by
7 posts views Thread by tina | last post: by
3 posts views Thread by Detlev Ahlgrimm | last post: by
4 posts views Thread by Phil Latio | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.