ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Don Dwoske" <...@loraxis.com>
Subject oracle stored function
Date Fri, 22 Sep 2006 14:39:32 GMT
I searched the list, and tried many, many things to get iBatis to work
with a stored FUNCTION (not a PROCEDURE), and I finally came up with
something that works - but to me, it looks pretty hacked.

My function :

   FUNCTION GetID(
                i_origin IN VARCHAR2,
                i_process IN VARCHAR2,
                i_person IN VARCHAR2 DEFAULT NULL)
   RETURN NUMBER;

iBatis relevant info :

    <statement id="getid" parameterMap="getid-params">
        BEGIN ? := REMOTEREG.P_REMOTEREG_REGISTER_REMOTE.GetID(?, ?, ?); END;
    </statement>

    <parameterMap id="getid-params" class="Model.RemoteReg.GetId">
        <parameter property="regId"     direction="Output" column="param0" />
        <parameter property="origin"    direction="Input" />
        <parameter property="process"   direction="Input" />
        <parameter property="person"    direction="Input" />
    </parameterMap>

I tried with all my might (really, I did) to get it working using a
procedure instead of a statement, but I just couldn't.  I also tried
with partial might to figure out how to get rid of that ugly param0 in
as the output parameter name to have it named something nicer.. but no
luck... I only figured that out by stepping through the code and
seeing what the result OracleParameterCollection had inside of it.

I looked through the NUnit tests and see a function declared in the
SQL code (FUNCTION GET_ACCOUNTS_FUNCTION) - but didn't see it tested
anywhere for an example.

I'm really just glad that I got something that works, but if anyone
knows a better way to accomplish calling a stored function that
returns a simple value, please let me know.

-Don

-- 

---------------------------------------
Donald Dwoske
Software Journeyman
http://www.loraxis.com/ddwoske

Mime
View raw message