Java Reference
In-Depth Information
Map m = new HashMap(2);
m.put("a", new Integer(7));
m.put("b", new Integer(5));
Integer val =
(Integer)sqlMap.queryForObject("Account.in_example", m);
INOUT parameters are parameters that are passed into a procedure and can be
changed by the procedure, as in the following example, which takes two numbers
and swaps them. Here is the code for the procedure (in Oracle PL/SQL ):
create procedure swap(a in out integer, b in out integer) as
temp integer;
begin
temp := a;
a := b;
b := temp;
end;
Here is the parameter map, mapped statement, and Java code to use it:
<parameterMap id="swapProcedureMap" class="java.util.Map">
<parameter property="a" mode="INOUT" />
<parameter property="b" mode="INOUT" />
</parameterMap>
<procedure id="swapProcedure" parameterMap="swapProcedureMap">
{ call swap(?, ?) }
</procedure>
// Call swap function
Map m = new HashMap(2);
m.put("a", new Integer(7));
m.put("b", new Integer(5));
Integer val =
(Integer) sqlMap.queryForObject("Account.in_example", m);
OUT parameters are a bit more peculiar. They are similar to results (as in resultMap
results), but are passed in like parameters. The value passed in is ignored and
then replaced with a return value from the stored procedure. An OUT parameter
can return anything from a single value (as in our next example) to a complete
set of records (as in the case of an Oracle REFCURSOR ).
Here is an example of a somewhat trivial stored procedure that uses two IN
parameters and an OUT parameter (Oracle PL/SQL ):
create or replace procedure maximum
(a in integer, b in integer, c out integer) as
begin
if (a > b) then c := a; end if;
if (b >= a) then c := b; end if;
end;
Search WWH ::




Custom Search