<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 &quot;python setup.py install&quot; 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>&nbsp;</div>
<div>I will try out the Sybase.py you posted. Will keep you informed.<br><br>&nbsp;</div>
<div><span class="gmail_quote">On 10/26/05, <b class="gmail_sendername">Nidositko, James</b> &lt;<a href="mailto:James.Nidositko@gs.com">James.Nidositko@gs.com</a>&gt; 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>&nbsp;</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).&nbsp; I was under the impression that these fixes had been incorporated and released, but I did not check that before responding to your question.&nbsp; Sorry for the confusion.</font></span></div>
<div dir="ltr" align="left"><span><font face="Lucida Sans" color="#0000ff" size="2"></font></span>&nbsp;</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.&nbsp; There were extensive changes to the structure of the code between that version and the actual 
0.36 release.&nbsp; 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>&nbsp;</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>&nbsp;</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.&nbsp; 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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ''' Connects to database specified, exec the SQL and returns value'''<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; db = 
Sybase.connect(Svr, Login,Pass ,Db)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nb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bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; except Sybase.DatabaseError:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 9<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; except:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return 2
<br><br>stmt = '''<br>update table<br>set col_1 =&nbsp; 1<br>where login = &quot;user&quot;<br>'''<br><br>exec_updtstmt(Svr,Login,Pass,DbInt,stmt)<br><br>what i got is &quot;Cursor rowcount after update (no rows) is: -1&quot; 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> &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:James.Nidositko@gs.com" target="_blank">James.Nidositko@gs.com
</a>&gt; 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 &quot;return value&quot; from an executed SQL<br>
statement.&nbsp;&nbsp;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)&nbsp;&nbsp;Rowcount does work.&nbsp;&nbsp;Here is some sample code that will show rowcount
<br>working in various situations.<br><br>&nbsp;&nbsp;c=dbc.cursor()<br>&nbsp;&nbsp;print &quot;Cursor rowcount is initialized to: %d&quot; % c.rowcount<br>&nbsp;&nbsp;c.execute (&quot;create table __test_rowcount (col1 varchar(10) NULL)&quot;)<br>&nbsp;&nbsp;print &quot;Cursor rowcount after create table is: %d&quot; % 
c.rowcount<br><br>&nbsp;&nbsp;c.execute(&quot;insert __test_rowcount (col1) values ('asdf')&quot;) <br>&nbsp;&nbsp;print &quot;Cursor rowcount after insert 1 is: %d&quot; % c.rowcount<br><br>&nbsp;&nbsp;c.execute(&quot;insert __test_rowcount (col1) values ('asdf')&quot;)
<br>&nbsp;&nbsp;print &quot;Cursor rowcount after insert 2 is: %d&quot; % c.rowcount <br><br>&nbsp;&nbsp;c.execute(&quot;update __test_rowcount set col1 = 'qwer' where col1 = 'asdf'&quot;)<br>&nbsp;&nbsp;print &quot;Cursor rowcount after update is: %d&quot; % 
c.rowcount<br><br>&nbsp;&nbsp;c.execute(&quot;update __test_rowcount set col1 = 'qwer' where col1 = 'not <br>there'&quot;)<br>&nbsp;&nbsp;print &quot;Cursor rowcount after update (no rows) is: %d&quot; % c.rowcount<br><br>&nbsp;&nbsp;c.execute(&quot;select count(*) from&nbsp;&nbsp;__test_rowcount&quot;)
<br>&nbsp;&nbsp;print &quot;Cursor rowcount after execute for select is: %d&quot; % c.rowcount<br>&nbsp;&nbsp;c.fetchall()<br>&nbsp;&nbsp;print &quot;Cursor rowcount after fetch for select is: %d&quot; % c.rowcount<br><br>&nbsp;&nbsp;c.execute(&quot;delete __test_rowcount where col1 = 'qwer'&quot;)
<br>&nbsp;&nbsp;print &quot;Cursor rowcount after delete is: %d&quot; % c.rowcount<br><br>The only unusual case is select.&nbsp;&nbsp;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>&nbsp;&nbsp; 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 &lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:mik3l3374@gmail.com" target="_blank">mik3l3374@gmail.com</a>&gt;
<br>Subject: [python-sybase] how to get return value of update/delete<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;statement<br>To: Python Sybase &lt;<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>&gt;<br>Message-ID:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:e3202a160510250330t7306ecd6p79b4517d42e5bc2c@mail.gmail.com" target="_blank">
e3202a160510250330t7306ecd6p79b4517d42e5bc2c@mail.gmail.com</a>&gt;<br>Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<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&nbsp;&nbsp;eg if key in wrong username, my CGI script will<br>call Sybase to execute &lt; update table set this = a-value where name =
<br>'wronguser' &gt; and then return a value indicating &quot;not found&quot; <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>