Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > how to return correct value of update stmt

Reply
Thread Tools

how to return correct value of update stmt

 
 
eight02645999@yahoo.com
Guest
Posts: n/a
 
      10-19-2005
hi
i use odbc to update a table in a database but i always get return
value of -1
even though i tried to return an integer. the table is updated though
....
sql = """
update table
set column = 0
where col = "%s"
select @@rowcount

""" % (var1)
.....
try:
s = odbc.odbc(connectstring)
cur = s.cursor()
res = cur.execute(sql)
s.commit()
s.close()
cur.close()
s = None
cur = None
print res
return res
except:
print 'error while processing ', sys.exc_type,sys.exc_value


how to properly get a positive return ?
thanks

 
Reply With Quote
 
 
 
 
Steve Holden
Guest
Posts: n/a
 
      10-19-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> hi
> i use odbc to update a table in a database but i always get return
> value of -1
> even though i tried to return an integer. the table is updated though
> ...
> sql = """
> update table
> set column = 0
> where col = "%s"
> select @@rowcount
>
> """ % (var1)
> ....
> try:
> s = odbc.odbc(connectstring)
> cur = s.cursor()
> res = cur.execute(sql)
> s.commit()
> s.close()
> cur.close()
> s = None
> cur = None
> print res
> return res
> except:
> print 'error while processing ', sys.exc_type,sys.exc_value
>
>
> how to properly get a positive return ?
> thanks
>

Is the table actually being updated?

The definition of the cursor.execute() method in

http://www.python.org/peps/pep-0249.html

specifically says "Return values are not defined". So if you are seeing
the database do the right thing I'd stop worrying about the return
value. If exceptions aren't being raised and the database is doing what
you want, what's the problem?

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

 
Reply With Quote
 
 
 
 
eight02645999@yahoo.com
Guest
Posts: n/a
 
      10-19-2005
hi
yes , the table is updated. Just feels "uncomfortable" with the return
of -1.
was also concerned that what if the actual table doesn't exist, will it
return -1?
anyway, i will go check it out ..
thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
PSL stmt embedded in VHDL: good tutorials somewhere? Eric DELAGE VHDL 2 04-06-2005 05:11 AM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
AAA vs. pw on line stmt Cisco 1 02-28-2004 10:21 AM
How to pass special characters in Update stmt!! Jay ASP .Net 3 10-31-2003 12:30 AM



Advertisments