ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher.Mathru...@sybase.com
Subject Insert/update issues
Date Fri, 24 Mar 2006 17:38:57 GMT

<br><font size=2 face="sans-serif">I'm working with Sybase ASE 12 using
JConnect 6.0 JDBC driver. The problem that I am having is when I perform
an insert or an update into a table that has a trigger, and the trigger
calls RaiseError, the error does not get converted into an SQLException.
&nbsp;It appears that this information will be sent back to the calling
application in the form of a resultSet. Seeing as a call to execute() could
return multiple ResultSets, I'm told the proper way to access this information
is to retrieve all resultSet returned by the PreparedStatement. </font>
<br>
<br><font size=2 face="sans-serif">The JDBC API docs do make reference
to this:</font>
<br><font size=3>The </font><font size=3><tt>execute</tt></font><font
size=3>
method returns a </font><font size=3><tt>boolean</tt></font><font
size=3>
to indicate the form of the first result. You must call either the method
</font><font size=3><tt>getResultSet</tt></font><font size=3>
or </font><font size=3><tt>getUpdateCount</tt></font><font
size=3>
to retrieve the result; you must call </font><font size=3><tt>getMoreResults</tt></font><font
size=3>
to move to any subsequent result(s). </font>
<br>
<br><font size=2 face="sans-serif">I'm told the following:</font>
<br>
<br><font size=3>Some methods only handle a single result and anything
but the single result will be an exception. When you consider stored procedures
in particular there is practically anything that can be returned. e.g.<br>
<br>
create proc xx as<br>
 &nbsp; select * from table &nbsp; &nbsp;==&gt; this only throw exception
if something like the table has been dropped etc. <br>
 &nbsp; raiserror xxx<br>
 &nbsp; select 1 <br>
 &nbsp; etc. <br>
<br>
Any method of query that only expects a single result is never going to
see the raiserror. &nbsp;Because it does not read the results far enough
to get to the error.<br>
<br>
<br>
result from server = &nbsp;|1. results set rows | 2. &nbsp;results message
| 3. results set rows | end of results |<br>
<br>
So consider results consisting of 3 different result sets if only result
#1 was read by the method and the program went on then the #2 results message
would <br>
not be read unless you used a method like &lt;statement&gt;.execute() and
process all results. &nbsp;Trigger output is like this. <br>
<br>
If let's say there were something wrong with the first select and there
was not a row result but a message, then you would see the SQLException
in the simple method like &lt;statement&gt;.executeQuery() .</font>
<br>
<br>
<br>
<br>
<br><font size=2 face="sans-serif">So what is my work around? How can I
configure iBatis so I can receive the error raised by the trigger?</font>
<br>
<br><font size=2 face="sans-serif">Thanks...</font>
<br><font size=2 face="sans-serif"><br>
Chris Mathrusse<br>
christopher.mathrusse@sybase.com<br>
Sybase, Inc<br>
One Sybase Drive<br>
Dublin, CA 94568<br>
(925) 236-5553</font>

Mime
View raw message