Determining Success or Failure status on SQL update in ZSQL Metho d d
Hello, A search of prior discussion threads shows this question occasionally appears without resolution. Perhaps someone has found an answer to it since then, so here it is... Using a ZSQL method, how do I detect if any rows have been affected when performing a SQL UPDATE. I do not need to know how many rows, just whether the statement affected 0 rows or more than 0 rows. My environment is Oracle (7 & 8) and with other programmatic interfaces to Oracle, one can capture a (non-error) return status that indicates if no rows were affected. This is supported in the ODBC API for Oracle and other databases as well. Is there a way to capture this return status even though it is not flagged as an error? No dtml-try since it's only a return code, not an error code As a workaround I've tried to do a select count, but to do this I need to 1) execute the select and update in the same transaction and 2) run the select before the update, store the value, then return it at the end (the update may or will change at least one of the fields referenced in the where clause, so I cannot run it after) So, inside of a SQL method, I can do #1, but cannot see a way to do #2. Is there a secret trick to this or is it a case of adding code to the existing DAs? Please please tell me it's the former. Thanks in advance, Ira
what about <dtml-let "rows_affected=sql_query(params=param)">? and then check if rows_affected is >0 Regards, Matthew Parslow On Thu, 17 Feb 2000, you wrote:
Hello,
A search of prior discussion threads shows this question occasionally appears without resolution. Perhaps someone has found an answer to it since then, so here it is...
Using a ZSQL method, how do I detect if any rows have been affected when performing a SQL UPDATE. I do not need to know how many rows, just whether the statement affected 0 rows or more than 0 rows.
My environment is Oracle (7 & 8) and with other programmatic interfaces to Oracle, one can capture a (non-error) return status that indicates if no rows were affected. This is supported in the ODBC API for Oracle and other databases as well. Is there a way to capture this return status even though it is not flagged as an error?
No dtml-try since it's only a return code, not an error code
As a workaround I've tried to do a select count, but to do this I need to 1) execute the select and update in the same transaction and 2) run the select before the update, store the value, then return it at the end (the update may or will change at least one of the fields referenced in the where clause, so I cannot run it after)
So, inside of a SQL method, I can do #1, but cannot see a way to do #2.
Is there a secret trick to this or is it a case of adding code to the existing DAs? Please please tell me it's the former.
Thanks in advance, Ira
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (2)
-
Ira Hochman -
Matthew Parslow