1 package smile.stored; 2 3 import java.util.*; 4 import java.sql.*; 5 6 17 public class s_editUserToGroup extends StoredProcedure implements ProcedureInterface { 18 19 String in_userID; 21 22 String in_groupID; 23 24 String ifexists; 25 26 public s_editUserToGroup() { 27 } 28 29 public void init(HashMap initData, Connection con) { 30 super.init(initData, con); 32 in_userID = utils.getString(data, "USERID", ""); 34 in_groupID = utils.getString(data, "GROUPID", ""); 35 action = utils.getString(data, "ACTION", ""); 36 } 37 38 public void checkAction() throws SQLException { 39 ifexists = execStatementToValue("SELECT count(*) FROM tblpermusergroup WHERE userID = " + in_userID + " AND groupID = " + in_groupID); 40 close(); 41 } 42 43 public void checkParams() throws SQLException { 44 } 45 46 public void executeAction() throws SQLException { 47 if (ifexists.equals("0")) { 48 if (action.equals("1")) { 49 StringBuffer v_sb = new StringBuffer (); 50 v_sb.append("INSERT into tblpermusergroup ").append(" values (" + in_userID + ", " + in_groupID + ")"); 51 52 execStatement(v_sb.toString()); 53 } 54 } else if (ifexists.equals("1")) { 55 if (action.equals("0")) { 56 StringBuffer v_sb = new StringBuffer (); 57 v_sb.append("DELETE FROM tblpermusergroup ").append(" WHERE userID = " + in_userID + " ").append(" AND groupID = " + in_groupID); 58 59 execStatement(v_sb.toString()); 60 } 61 } 62 execStatementToRS(queryResultOk); 63 } 64 } | Popular Tags |