Menu

Oracle function with ref cursor

l_yara
2006-08-23
2013-04-25
  • l_yara

    l_yara - 2006-08-23

    Hi All,
    I'm trying to test the function (SQLUnit 5.0, Oracle 10g)
    --- Oracle PL/SQL code ---
      function getMetadataFieldsInfo(p_ObjectType varchar2)
        return FieldInfoCursor is
        ret FieldInfoCursor;
        l   FieldInfoType;
      begin
        if p_ObjectType is not null then
          open ret for
            select 'aaa' cFldName, 'ddd' cFldType, 1 isReference from dual;
        end if;
        return ret;
      end;
    -----

    Test code:
    -----
    <connection reconnect-on-failure="on"
            extern="sqlunit-connection.properties" connection-id="1" />
    <test name="STAGE.gasdiststat input">
        <call connection-id="1">
        <stmt>{?=call getmetadatafieldsinfo(?)}</stmt>
            <param id="1" type="CURSOR" inout="out" name="res" is-null="true"/>
            <param id="2" type="VARCHAR" inout="in" name="p_objecttype">STAGE.gasdiststat</param>
        </call>
        <result echo="false">
            <outparam id="1" type="CURSOR">
                <resultset id="1" partial="false" rowcount="1"/>
                </outparam>
        </result>
    </test>
    ------

    Result looks somewhat strange:
    ----------
      [sqlunit] *** Running SQLUnit file: C:\Documents and Settings\Yaroslav\workspace\Migrator\sripts\packages\MIGRATOR_MAPPING\getmetadatafieldsinfo.xml
      [sqlunit] Getting connection(1)
      [sqlunit] Setting up test...
      [sqlunit] Running test[1]: STAGE.gasdiststat input (0ms)
      [sqlunit] org.jdom.Element.addContent(Lorg/jdom/Element;)Lorg/jdom/Element;
      [sqlunit] Tearing down test...
      [sqlunit] sqlunit-ant: SQLUnit Tests Failed: In file: C:....
    -------------
    It looks like the string
    ... [sqlunit] org.jdom.Element.addContent(Lorg/jdom/Element;)Lorg/jdom/Element;...

    subsitutes the actual output from the function (the same problem arises during any test failure - the string org.jdom.Element.addContent... arises instead of failure report).

    What is the right syntax for testing REF CURSOR output?

     
    • l_yara

      l_yara - 2006-08-29

      The problem does not appear with SQLUnit version 4.9

       
    • Sujit Pal

      Sujit Pal - 2006-09-06

      This seems to be the same problem as the one with the <result echo="true" />, but I cannot reproduce this, perhaps my test case is too simplistic. Can you provide the test in that thread?

      Thanks

      -sujit

       

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.