ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brett Knights <br...@knightsofthenet.com>
Subject Stored Procedure with variable parameters
Date Tue, 06 Feb 2007 07:46:29 GMT

I am using ibatis as my persistence layer in an application that I'm 
rewriting. I have some older code that uses JDBC directly and I can't 
see how to integrate it with iBatis in any useful way.

The old code calls a stored procedure. After contact information is set 
the number of arguments that might be set is arbitrary up to 100 extra 
arguments. Is there any way to do this with a SQLMap? I suppose I can 
just move the jdbc code inside my DAO object and then flush the caches 

TIA for any advice.

         CallableStatement pstmt = SQLCallUtil.prepareCallable(con, 
"tewouPlaceUpdate", true, 117); // build the "{ ? =  call   
tewouPlaceUpdate ? ? ? ? ... ?}" string with 117 parameter placeholders
         pstmt.registerOutParameter(1, java.sql.Types.INTEGER);
         pstmt.registerOutParameter(2, java.sql.Types.INTEGER);
         pstmt.setInt(3, iOwnerId);
         pstmt.registerOutParameter(4, java.sql.Types.INTEGER);
         pstmt.setInt(4, iContactId);
         pstmt.setString(5, contactFirstName);
         pstmt.setString(6, contactLastName);
         pstmt.setString(7, contactTitle);
         pstmt.setString(8, contactAddr1);
         pstmt.setString(9, contactAddr2);
         pstmt.setString(10, contactAddr3);
         pstmt.setString(11, contactCity);
         pstmt.setString(12, contactCtryCode);
         pstmt.setString(13, contactRegn);
         pstmt.setString(14, contactPC);
         pstmt.setString(15, contactPhone);
         pstmt.setString(16, contactFax);
         pstmt.setString(17, contactEmail);
         pstmt.setInt(18, isPlaceable ? 1 : 0);

         int k = 18;
         Iterator packageIds = updateIds.iterator();
         while(packageIds.hasNext())pstmt.setString(++k, (String) 

         for(;k < 118; ) pstmt.setNull(++k, java.sql.Types.VARCHAR); // 
null the remaining params

View raw message