KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > smile > stored > s_updateModes


1 package smile.stored;
2
3 import java.util.*;
4 import java.sql.*;
5
6 /**
7  * s_updateModes is an implements the ProcedureInterface and is a sub-class of
8  * StoredProcedure. Copyright 2002 Smile Les motoristes Internet
9  * http://www.smile.fr/ Contact cofax@smile.fr for further information
10  *
11  * @author Smile Les motoristes Internet
12  * @created March 22, 2002
13  */

14 public class s_updateModes extends StoredProcedure implements ProcedureInterface {
15
16     // proprietes propres a cette stored proc
17
String JavaDoc in_mode;
18
19     String JavaDoc in_type;
20
21     String JavaDoc in_delete;
22
23     String JavaDoc in_newmodeid;
24
25     String JavaDoc in_rowexists;
26
27     /**
28      * Constructor for the s_updateModes object
29      */

30     public s_updateModes() {
31     }
32
33     /**
34      * Description of the Method
35      *
36      * @param initData
37      * Description of the Parameter
38      * @param con
39      * Description of the Parameter
40      */

41     public void init(HashMap initData, Connection con) {
42         // on initialise le hashmap de donnees et la connection de l'objet
43
super.init(initData, con);
44         // on initialise les propprietes de l'objet
45
in_mode = utils.getString(data, "MODES", "");
46         in_type = utils.getString(data, "TYPE", "");
47         in_delete = utils.getString(data, "DELETE", "");
48     }
49
50     /**
51      * Description of the Method
52      *
53      * @exception SQLException
54      * Description of the Exception
55      */

56     public void checkParams() throws SQLException {
57     }
58
59     /**
60      * Description of the Method
61      *
62      * @exception SQLException
63      * Description of the Exception
64      */

65     public void checkAction() throws SQLException {
66
67         if (in_delete.equals("0")) {
68             StringBuffer JavaDoc v_sb = new StringBuffer JavaDoc();
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     /**
82      * Description of the Method
83      *
84      * @exception SQLException
85      * Description of the Exception
86      */

87     public void executeAction() throws SQLException {
88         String JavaDoc newQueryResultOk = "select 1 as returnValue";
89         if (action.equals("delete")) {
90             StringBuffer JavaDoc v_sb = new StringBuffer JavaDoc();
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 JavaDoc v_sb = new StringBuffer JavaDoc();
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