You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by C....@ads.it on 2006/10/13 17:46:22 UTC
Re: Dynamic packages (works! :)
Hi Jeff.
Thanks for the help.
It works fine! :)
To help any other beginner that will face the issue go dyamic spcification
of a package name (or othe parts of the SQL statement to be prepared)
here follow the code snippets
SQL Map
<procedure id="dynamic_package_id" parameterClass="java.util.Map">
{ call $packageName$.get_key_2_out_basic(
#outParam,javaType=java.lang.Integer,mode=OUT,jdbcType=INTEGER# ) }
</procedure>
Java
HashMap< String, Object > lHashMap = new HashMap< String, Object >();
lHashMap.put("packageName", "ut_Foo");
try
{
lSqlMapClient.update( "dynamic_package_id", lHashMap );
}
catch (SQLException pException)
{
pException.printStackTrace();
throw pException;
}
Integer lInteger = (Integer) lHashMap.get("outParam");
assertEquals( 5, lInteger.intValue() );
PL/SQL
(ut parts not relevant have been omitted)
specification
create or replace package ut_foo is
procedure get_key_2_out_basic( p_PK out number );
pragma restrict_references( get_key_2_out_basic, WNDS );
end ut_foo;
body
create or replace package body ut_foo is
procedure ut_setup
is
begin
null;
end;
procedure ut_teardown
is
begin
null;
end;
procedure get_key_2_out_basic( p_PK out number )
is
begin
p_PK := 5;
end;
begin
null;
end ut_foo;
I hope it will help for other newcomers.
ciao