473,779 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to return correct value of update stmt

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(conne ctstring)
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,sy s.exc_value
how to properly get a positive return ?
thanks

Oct 19 '05 #1
2 1659
ei***********@y ahoo.com 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(conne ctstring)
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,sy s.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/

Oct 19 '05 #2
hi
yes , the table is updated. Just feels "uncomforta ble" 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

Oct 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2469
by: Chris Cox | last post by:
Hi, Hoping someone can help, I have a sql query which is passed to the script via the url, this is like:- &stmt=select%20*%20from%20table%20where%20(%20status!='Closed'%20..... If I look at $_GET, this gives:- select * from tickets where ( status=''Closed'' ...... If I look at $HTTP_GET_VARS, this gives:-
14
47906
by: John | last post by:
Hi all, I am doing the change from having worked in Oracle for a long time to MS SQL server and am frustrated with a couple of simple SQL stmt's. Or at least they have always been easy. The SQL is pretty straightforward. I am updating a field with a Max effective dated row criteria. (PepopleSoft app) update PS_JOB as A set BAS_GROUP_ID = ' '
2
3854
by: claus.hirth | last post by:
I wrote a stored procedure that uses a prepared INSERT INTO statement in order to play with the PREPARE and EXECUTE keywords. In transcript 1 below the call to that stored procedure does not work. Yet transcript 2 shows that the stored procedure does its job, if only the table name is provided directly in the statement text string, instead of as a host variable to a prepared statement like in 'EXECUTE stmt USING tabName, fldValue'. --...
3
1954
by: Jay | last post by:
Hello, I need to use Update Sql stmt from my page. Some of the field values has apostrophes and and quotes. How do I make ado.net ignore those characters? Eg- UPDATE ROOM SET HEIGHT='3' - 5"' WHERE RMNU='100'
8
2352
by: MLH | last post by:
Here's a snippet from A97 HELP on AddNew... The record that was current before you used AddNew remains current. If you want to make the new record current, you can set the Bookmark property to the bookmark identified by the LastModified property setting. My own experience is indicating that the newly added record becomes current during the AddNew processes and REMAINS current after .Update method runs. This seems true even though the...
4
4719
by: zacks | last post by:
I have a DSN that I frequently have to change the default database. Is there a way to do this in VB.NET code instead of having to go through the setup wizard every time?
22
4044
by: semedao | last post by:
Hi , I am using asyc sockets p2p connection between 2 clients. when I debug step by step the both sides , i'ts work ok. when I run it , in somepoint (same location in the code) when I want to receive 5 bytes buffer , I call the BeginReceive and then wait on AsyncWaitHandle.WaitOne() but it is signald imidiatly , and the next call to EndReceive return zero bytes length , also the buffer is empty. here is the code: public static byte...
1
5715
by: komatouch09 | last post by:
Hi I am new to visual basic. I write program to navigate & update data from table. My database is in Informix & use ODBC connection. When I nevigate the data it works properly. When I Update the record its also updated but after that if I try to navigate it its giving error "Row cannot be located for updating. Some values may have been change since it was last read". My code is as follows - Option Explicit Dim cnn As Connection Dim...
5
1864
by: Yew12 | last post by:
I have been trying to update the details in a access database but, all I get is a white screen and all the errors I have built-in give me no help at all. All help is greatly appreciated. <html> <head><title> Customer Information Updated</title></head> <body> <?php
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9930
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.