title: MyBatis: Sybase stored procedure returns zero rows
body: <p>I have copied the text from here:
  <a href="http://code.google.com/p/mybatis/issues/detail?id=164" rel="nofollow">http://code.google.com/p/mybatis/issues/detail?id=164</a>, but we faced the same issue.</p>
  
  <p>MyBatis version 3.0.1</p>
  
  <p>I use MyBatis 3 as the OR mapping between the java application and sybase database.
  The sql used to query data from the database is a stored procedure, it is ok for simple procedure, but if there is inner variable declared and used in the stored procedure, it seems does not work correctly, the query result is null, while there is no exception throwing.</p>
  
  <p>below is the example code, and i also attach as the attachment.
  JavaBean:</p>
  
  <pre><code>
      public class Test {
  
      private String input1;
      private String input2;
  
      public String getInput1() {
          return input1;
      }
  
      public void setInput1(String input1) {
          this.input1 = input1;
      }
  
      public String getInput2() {
          return input2;
      }
  
      public void setInput2(String input2) {
          this.input2 = input2;
      }
      }
  </code></pre>
  
  <p>sqlMap:</p>
  
  <pre><code>
      &lt;mapper namespace="cargoStatus_shipment"&gt;
      &lt;resultMap id="testMap"     type="com.icil.esolution.cargoStatus.AS.model.Test"&gt;
      &lt;result column="result1" jdbcType="VARCHAR" property="input1" /&gt;
      &lt;result column="result2" jdbcType="VARCHAR" property="input2" /&gt;
      &lt;/resultMap&gt;
  
      &lt;select id="getValidData" statementType="CALLABLE"     resultMap="testMap"     parameterType="String"&gt;
       {call tempdb..testSP #{in}}
      &lt;/select&gt; 
  
      &lt;/mapper&gt;
  </code></pre>
  
  <p>stored procedure:</p>
  
  <pre><code>
      use tempdb
      go
      drop proc testSP
      go
      create proc testSP
        @in varchar(10)
  
      as
       declare @var char(3)
       select @var="XXX"
       select result1= '1', result2=@in
      go
      grant exec on testSP  to public
      go
  </code></pre>
  
  <p>Java code:</p>
  
  <pre><code>
  public class TestSP {
  
  
    private static SqlSessionFactory createSqlMapper() throws IOException {
          String resource = "resources/sqlMapConfig.xml";
          Reader reader = Resources.getResourceAsReader(resource);
          return new SqlSessionFactoryBuilder().build(reader,"development");
    }
  
  
    public static void main(String[] args) {
  
      SqlSession session=null;
      try {
            session = createSqlMapper().openSession(ExecutorType.SIMPLE, true); //autocommit = true
  
      } catch (Exception e) {
         e.printStackTrace();
         System.out.println("Error in open Session. Cause: " + e);
         System.exit(1);
      }
  
  
      List result = (List) session.selectList("getValidData", "mydata"); 
  
      System.out.println("Result = "+result);
      System.out.println(result.get(2).getInput2());
  
    }
  
  }
  </code></pre>
  
  <p>normally the result should be:</p>
  
  <pre><code>DEBUG PreparedStatement - ==>  Executing: {call tempdb..testSP ?} 
  DEBUG PreparedStatement - ==> Parameters: mydata(String)
  DEBUG ResultSet - </pre>
  
  <p>but actually, there is no result get, neither exceptions:</p>
  
  <pre><code>DEBUG PreparedStatement - ==>  Executing: {call tempdb..testSP ?} 
  DEBUG PreparedStatement - ==> Parameters: mydata(String)</code></pre>
  
  <p>after counter test, if i remove the inner variable @var from the sp, then it will be ok.</p>
  
  <pre>
      use tempdb
      go
      drop proc testSP
      go
      create proc testSP
        @in varchar(10)
  
      as
       select result1= '1', result2=@in
      go
      grant exec on testSP  to public
      go
  </code></pre>
  
  <p>Could you pls check what is the problem and what shall I do to make sure I can call this kind of stored procedure? </p>