1 package smile.stored; 2 3 import java.util.*; 4 import java.sql.*; 5 6 14 public class s_updateModes extends StoredProcedure implements ProcedureInterface { 15 16 String in_mode; 18 19 String in_type; 20 21 String in_delete; 22 23 String in_newmodeid; 24 25 String in_rowexists; 26 27 30 public s_updateModes() { 31 } 32 33 41 public void init(HashMap initData, Connection con) { 42 super.init(initData, con); 44 in_mode = utils.getString(data, "MODES", ""); 46 in_type = utils.getString(data, "TYPE", ""); 47 in_delete = utils.getString(data, "DELETE", ""); 48 } 49 50 56 public void checkParams() throws SQLException { 57 } 58 59 65 public void checkAction() throws SQLException { 66 67 if (in_delete.equals("0")) { 68 StringBuffer v_sb = new StringBuffer (); 69 v_sb.append("SELECT count(*) FROM tblpermmodes ").append(" WHERE modes = '" + in_mode + "'").append(" AND type = " + in_type); 70 71 in_rowexists = execStatementToValue(v_sb.toString()); 72 73 if (in_rowexists.equals("0")) { 74 action = "insert"; 75 } 76 } else { 77 action = "delete"; 78 } 79 } 80 81 87 public void executeAction() throws SQLException { 88 String newQueryResultOk = "select 1 as returnValue"; 89 if (action.equals("delete")) { 90 StringBuffer v_sb = new StringBuffer (); 91 v_sb.append("DELETE FROM tblpermmodes ").append(" WHERE modes = '" + in_mode + "'").append(" AND type = " + in_type); 92 93 execStatement(v_sb.toString()); 94 } else if (action.equals("insert")) { 95 StringBuffer v_sb = new StringBuffer (); 96 v_sb.append("INSERT INTO tblpermmodes ").append("(modes, type)").append(" VALUES ('" + in_mode + "', " + in_type + ")"); 97 98 execStatement(v_sb.toString()); 99 } 100 execStatementToRS(newQueryResultOk); 101 } 102 } 103 | Popular Tags |