<div>thanks for the help, appreciate that.</div>
<div>my version of Sybase ASE is 12.5</div>
<div>and when i did the compiling in Solaris 8, i use gcc and just "python setup.py install" and no</div>
<div>other flags or options. Don't know whether it has anything to do with that rowcount stuff , maybe my environment has something to do with it but anyway, just some info on my side on what i did....</div>
<div> </div>
<div>I will try out the Sybase.py you posted. Will keep you informed.<br><br> </div>
<div><span class="gmail_quote">On 10/26/05, <b class="gmail_sendername">Nidositko, James</b> <<a href="mailto:James.Nidositko@gs.com">James.Nidositko@gs.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div dir="ltr" align="left"><font face="Lucida Sans" color="#0000ff" size="2"></font> </div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2">Mike, </font></span></div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2">I had some discussions earlier this year with Dave about fixing the rowcount stuff in the recent versions of the Sybase module (0.36 and
0.37). I was under the impression that these fixes had been incorporated and released, but I did not check that before responding to your question. Sorry for the confusion.</font></span></div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2">The last official version that I know of where rowcount() worked was 0.36-pre2. There were extensive changes to the structure of the code between that version and the actual
0.36 release. The rowcount problems were introduced by some of those changes and carried forward into 0.37.</font></span></div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2">I'm assuming that you're using 0.37.</font></span></div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2">The attached copy of Sybase.py fixes the rowcount issues. It is based on the version released with 0.37.</font></span></div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2">Dave, any chance of getting an official release with rowcount() working?</font></span></div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2">-Jim</font></span></div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2"></font></span> </div><br>
<blockquote style="MARGIN-RIGHT: 0px">
<div lang="en-us" dir="ltr" align="left">
<hr>
<font face="Tahoma" size="2"><b>From:</b> mike [mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:mik3l3374@gmail.com" target="_blank">mik3l3374@gmail.com</a>] <br><b>Sent:</b> Wednesday, October 26, 2005 10:56 AM
<br><b>To:</b> Nidositko, James<br><b>Cc:</b> <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:python-sybase@www.object-craft.com.au" target="_blank">python-sybase@www.object-craft.com.au</a><br><b>Subject:
</b> Re: [python-sybase] how to get return value of update/delete<br></font><br> </div>
<div><span class="e" id="q_1072d9642f0295f0_1">
<div></div>hi thanks for the reply.<br>I went to try the codes out<br><br>def exec_updtstmt(Svr,Login,Pass,Db,SQL):<br> ''' Connects to database specified, exec the SQL and returns value'''<br> try:<br> db =
Sybase.connect(Svr, Login,Pass ,Db)<br> c = db.cursor() <br> try:<br> c.execute(SQL)<br> print "Cursor rowcount after update (no rows) is: %d" %
c.rowcount<br> db.commit()<br> db.close() <br> except Sybase.DatabaseError:<br> return 9<br> except:<br> return 2
<br><br>stmt = '''<br>update table<br>set col_1 = 1<br>where login = "user"<br>'''<br><br>exec_updtstmt(Svr,Login,Pass,DbInt,stmt)<br><br>what i got is "Cursor rowcount after update (no rows) is: -1" and when i checked the table
<br>it is updated. Although the update works, i would wish to get that return to indicate to the user whether success or failure<br>.<br>thanks for any further help<br><br><br><br><br>
<div><span class="gmail_quote">On 10/26/05, <b class="gmail_sendername">Nidositko, James</b> <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:James.Nidositko@gs.com" target="_blank">James.Nidositko@gs.com
</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid"><br>Mike,<br>There is no inherent concept of a "return value" from an executed SQL<br>
statement. You can produce such a result by encapsulating your SQL<br>statements within stored procedures by detecting the rowcount and setting <br>the return value in response, but there isn't really any need for you to do
<br>that.<br><br>1) It sounds like the error case that you're trying to describe below should<br>be detected by getting a rowcount of zero from the update. <br><br>2) Rowcount does work. Here is some sample code that will show rowcount
<br>working in various situations.<br><br> c=dbc.cursor()<br> print "Cursor rowcount is initialized to: %d" % c.rowcount<br> c.execute ("create table __test_rowcount (col1 varchar(10) NULL)")<br> print "Cursor rowcount after create table is: %d" %
c.rowcount<br><br> c.execute("insert __test_rowcount (col1) values ('asdf')") <br> print "Cursor rowcount after insert 1 is: %d" % c.rowcount<br><br> c.execute("insert __test_rowcount (col1) values ('asdf')")
<br> print "Cursor rowcount after insert 2 is: %d" % c.rowcount <br><br> c.execute("update __test_rowcount set col1 = 'qwer' where col1 = 'asdf'")<br> print "Cursor rowcount after update is: %d" %
c.rowcount<br><br> c.execute("update __test_rowcount set col1 = 'qwer' where col1 = 'not <br>there'")<br> print "Cursor rowcount after update (no rows) is: %d" % c.rowcount<br><br> c.execute("select count(*) from __test_rowcount")
<br> print "Cursor rowcount after execute for select is: %d" % c.rowcount<br> c.fetchall()<br> print "Cursor rowcount after fetch for select is: %d" % c.rowcount<br><br> c.execute("delete __test_rowcount where col1 = 'qwer'")
<br> print "Cursor rowcount after delete is: %d" % c.rowcount<br><br>The only unusual case is select. Then, the rowcount is not set until the<br>fetch is performed.<br><br>-Jim<br><br>-----Original Message-----
<br>From: <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:python-sybase-bounces@www.object-craft.com.au" target="_blank">python-sybase-bounces@www.object-craft.com.au</a><br>[mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:python-sybase-bounces@www.object-craft.com.au" target="_blank">
python-sybase-bounces@www.object-craft.com.au</a>] On Behalf Of<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:python-sybase-request@www.object-craft.com.au" target="_blank">python-sybase-request@www.object-craft.com.au
</a><br>Sent: Tuesday, October 25, 2005 10:00 PM<br>To: <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:python-sybase@www.object-craft.com.au" target="_blank">python-sybase@www.object-craft.com.au</a>
<br>Subject: Python-sybase Digest, Vol 5, Issue 3 <br><br><br>Today's Topics:<br><br> 1. how to get return value of update/delete statement (michael lee)<br><br><br>----------------------------------------------------------------------
<br><br>Message: 1<br>Date: Tue, 25 Oct 2005 18:30:07 +0800 <br>From: michael lee <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:mik3l3374@gmail.com" target="_blank">mik3l3374@gmail.com</a>>
<br>Subject: [python-sybase] how to get return value of update/delete<br> statement<br>To: Python Sybase <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:python-sybase@www.object-craft.com.au" target="_blank">
python-sybase@www.object-craft.com.au</a>><br>Message-ID:<br> <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:e3202a160510250330t7306ecd6p79b4517d42e5bc2c@mail.gmail.com" target="_blank">
e3202a160510250330t7306ecd6p79b4517d42e5bc2c@mail.gmail.com</a>><br>Content-Type: text/plain; charset="iso-8859-1"<br><br>hi<br>how can i successfully get the return of an update or delete statement using<br>
the Sybase module?<br>i am doing a CGI script whereby if a user keys in the wrong name, i would <br>want to catch that error eg if key in wrong username, my CGI script will<br>call Sybase to execute < update table set this = a-value where name =
<br>'wronguser' > and then return a value indicating "not found" <br>but i am not able to figure out how to catch this return value. Any advise?<br>....<br>cur.execute(update_statement)<br>....<br>my table is being updated though when i tried a valid user. I tried
<br>rowcount but also not working. <br>thanks<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL:<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.object-craft.com.au/pipermail/python-sybase/attachments/20051025/" target="_blank">
http://www.object-craft.com.au/pipermail/python-sybase/attachments/20051025/ </a><br>0c35109c/attachment-0001.html<br><br>------------------------------<br><br>_______________________________________________<br>Python-sybase mailing list
<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Python-sybase@www.object-craft.com.au" target="_blank">Python-sybase@www.object-craft.com.au </a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="https://www.object-craft.com.au/cgi-bin/mailman/listinfo/python-sybase" target="_blank">
https://www.object-craft.com.au/cgi-bin/mailman/listinfo/python-sybase</a><br><br><br>End of Python-sybase Digest, Vol 5, Issue 3<br>*******************************************<br></blockquote></div><br></span></div></blockquote>
<br clear="all"></blockquote></div><br>