You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "Devine, James" <ja...@fmr.com> on 2008/06/12 23:09:42 UTC
Null Parameter Checking
Hello,
I am using iBatis to run Sybase SP's.
In our SP's we have logic like this to check required parameters:
if (@id is null)
begin
select @error = 21000
select @message = "Input Argument @id is Null, procedure
terminated."
raiserror @error @message
return -1
end
Our sql map looks like this...
<parameterMap id="pmap" class="map">
<parameter property="id" javaType="java.lang.Integer"
jdbcType="INTEGER" mode="IN"/>
</parameterMap>
<procedure id="sp" parameterMap="pmap">
{CALL someSP(?)}
</procedure>
I was expecting to get a SQLException if a null id was passed in, but
instead, it is returning a result of 1 (I assume to indicate failure).
2 questions:
1) Do you know if this can be configured to throw an exception?
2) Do you know why this is returning 0 for success and 1 for failure
instead of the impacted row count (as stated in the java doc for
SqlMapExecutor.update())?
Thanks in advance,
Jim
RE: Null Parameter Checking
Posted by "Devine, James" <ja...@fmr.com>.
Sorry, I guess this was a Sybase issue...nothing to do with iBatis.
To fix this issue, you need to supply the connection with property
IGNORE_DONE_IN_PROC=true
JDBC: jdbc:sybase:xxx:host:port?IGNORE_DONE_IN_PROC=true
JNDI: Add/append it to the custom property named customProperties
(SELECT_OPENS_CURSOR=true;IGNORE_DONE_IN_PROC=true)
_____
From: Devine, James
Sent: Thursday, June 12, 2008 5:10 PM
To: user-java@ibatis.apache.org
Subject: Null Parameter Checking
Hello,
I am using iBatis to run Sybase SP's.
In our SP's we have logic like this to check required
parameters:
if (@id is null)
begin
select @error = 21000
select @message = "Input Argument @id is Null, procedure
terminated."
raiserror @error @message
return -1
end
Our sql map looks like this...
<parameterMap id="pmap" class="map">
<parameter property="id" javaType="java.lang.Integer"
jdbcType="INTEGER" mode="IN"/>
</parameterMap>
<procedure id="sp" parameterMap="pmap">
{CALL someSP(?)}
</procedure>
I was expecting to get a SQLException if a null id was passed
in, but instead, it is returning a result of 1 (I assume to indicate
failure). 2 questions:
1) Do you know if this can be configured to throw an exception?
2) Do you know why this is returning 0 for success and 1 for
failure instead of the impacted row count (as stated in the java doc for
SqlMapExecutor.update())?
Thanks in advance,
Jim