Menu

Syntax for SQLServer

Rick
2005-06-22
2013-04-25
  • Rick

    Rick - 2005-06-22

    I'm trying to get the following test to work:
      <test name="Getting an objective name">
        <call>
          <stmt>{? = call GetObjectiveName(?)}</stmt>
          <param id="1" type="INTEGER">1201</param>   
          <param id="2" type="VARCHAR" inout="out">${rc}</param>
        </call>
        <result>
          <outparam id="2" type="VARCHAR">Number Concepts</outparam>
        </result>
      </test>

    But it returns NULL as an output parameter and gives the following:
      [sqlunit]   <exception>
      [sqlunit]     <code>0</code>
      [sqlunit]     <message>[TDS Driver]Empty Parameter:1</message>
      [sqlunit]   </exception>
      [sqlunit] </result>

    It should be returning "Number Concepts" and the stored procedure is correct.

    Any ideas?

     
    • James Henderson

      James Henderson - 2005-06-23

      Hi Rick,

      One thing that I noticed is that your parameters should be reversed.  Parameters are numbered from left to right, starting with an id of "1".  The first parameter should be your return code.

      That is, your code should be:
      <call>
      <stmt>{? = call GetObjectiveName(?)}</stmt>
      <param id="1" type="VARCHAR" inout="out">${rc}</param> 
      <param id="2" type="INTEGER">1201</param> 
      </call>

      Second, since I believe stored procedures only return integers as return codes, your expected result is also incorrect. It should be:

      <result>
      <outparam id="1" type="INTEGER">0</outparam>
      </result>

      or something similar, since the return code is the first parameter.

      If you are using an OUTPUT parameter as the second parameter, then you will need to make the second parameter an "inout", and specify a second <outparam> within the <result>.  If your stored procdure returns a result set, then you will need to specify a <resultset> in addition to the <outparam> for the return code within the <result>.

      Hope this helps.

      -jh

       
    • Rick

      Rick - 2005-06-24

      Thanks for the pointers.  I've got it working better now - but I keep getting one error: 
      [sqlunit] outparam[2].id(3) out of bounds
        [sqlunit] Tearing down test...
        [sqlunit] sqlunit-ant: SQLUnit Tests Failed: In file: test/ms-sql/test.xml, te
      sts: 1, failures: 1, errors = 0

      Here is my new syntax:
        <test name="Getting an objective name">
          <call>
            <stmt>{? = call GetObjectiveName(?,?)}</stmt>
            <param id="1" type="INTEGER" inout="out" is-null="false" name="ReturnValue">${retval}</param>
            <param id="2" type="INTEGER" inout="in" name="IN_ObjId" >1201</param>   
            <param id="3" type="VARCHAR" inout="out" name="OUT_ObjName">${rc}</param>
          </call>
          <result>
            <outparam id="1" type="INTEGER">0</outparam>
            <outparam id="3" type="VARCHAR">Number Concepts</outparam>
          </result>
        </test>

      Any ideas about the out of bounds error?

       
    • James Henderson

      James Henderson - 2005-06-24

      Hi Rick,

      It looks like you're running into the same problem that I ran into when I pulled SQLUnit 4.8.  Check out the following thread:

      http://sourceforge.net/forum/forum.php?thread_id=1294550&forum_id=265576

      If you pull a the files mentioned in this thread from CVS, place them in the proper location within the "src" directory, and rebuild (using the command ant install), it should solve the problem.

      Your other choice is to download the SQLUnit 4.7 tarball which does not exhibit this behavior.

      Hope this helps.

      -jh

       
    • Rick

      Rick - 2005-06-24

      Thanks.  That did the trick.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.