public boolean deleteTable(){
Environment env = Environment.getStandardEnvironment(processData);
Database db = SystemWorkspace.getConnectionsWorkspace().getDatabase("MOVEX", env);
Table table = RepositoryUtil.getTable("Repository", "Table");
DeleteStatement delTable = new DeleteStatement(table, env.getSessionValues(), env.getDataTypeHandler(), db);
delTable.addWhere("CHAMP1", "VALEUR1");
delTable.addWhere("CHAMP2", "VALEUR2");
delTable.addWhere("CHAMP3", "VALEUR3");
delTable.addWhere("CHAMP4", "VALEUR4");
delTable.addWhere("CHAMP5", "VALEUR5");
try {
delTable.executeAndClose();
} catch (SQLException e) {
e.printStackTrace();
}
return true;
}
public boolean insertTable(){
Environment env = Environment.getStandardEnvironment(processData);
Database db = SystemWorkspace.getConnectionsWorkspace().getDatabase("MOVEX", env);
Table table = RepositoryUtil.getTable("Repository", "Table");
InsertStatement insTable = new InsertStatement(table, env.getSessionValues(), env.getDataTypeHandler(), db);
insTable.addColumnValue("CHAMP1", "VALEUR1");
insTable.addColumnValue("CHAMP2", "VALEUR2");
insTable.addColumnValue("CHAMP3", "VALEUR3");
insTable.addColumnValue("CHAMP4", "VALEUR4");
try {
insTable.executeAndClose();
} catch (SQLException e) {
e.printStackTrace();
}
}
return true;
}
ArrayList<String[]> selectTable(){
ArrayList<String[]> result = new ArrayList<String[]>();
Environment env = Environment.getStandardEnvironment(processData);
Database db = SystemWorkspace.getConnectionsWorkspace().getDatabase("NomDuRepository", env);
Table table = RepositoryUtil.getTable("NomDuRepository", "NomDeLaTable");
SelectStatement selTable = new SelectStatement(table, env.getSessionValues(), env.getDataTypeHandler(), db);
selTable.addSelectColumn("NomDuChamp1");
selTable.addSelectColumn("NomDuChamp2");
selTable.addSelectColumn("NomDuChamp3");
//selTable.setDistinct(true); // Ajout d'une clause DISTINCT
selTable.addWhere("NomDuChamp1", "valeur");
selTable.addWhere("NomDuChamp2", "valeur");
selTable.addWhere("NomDuChamp3", SqlParameter.GE, "valeur"); // SqlParameter.GE pour ">="
selTable.addWhere("NomDuChamp4", SqlParameter.LE, "valeur"); // SqlParameter.LE pour "<="
selTable.addOrderBy("NomDuChamp1").setSortOrder(SqlOrderByColumn.DESC); // Tri décroissant sur NomDuChamp1
selTable.addOrderBy("NomDuChamp2").setSortOrder(SqlOrderByColumn.ASC); // Tri croissant sur NomDuChamp2
SqlResult resTable = selTable.execute();
try {
while(resTable.next()){
String[] donnees = {resTable.getData("NomDuChamp1"), resTable.getData("NomDuChamp2"), resTable.getData("NomDuChamp3")};
result.add(donnees);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (resTable != null) resTable.close();
}
return result;
}
Méthode | Equivalence SQL |
EQ | = |
LE | <= |
GE | >= |
LT | < |
GT | > |
NE | <> |
NE2 | != |
RANGE | RANGE |
LIKE | LIKE |
NOT_LIKE | NOT LIKE |
IS_NULL | IS NULL |
IS_NOT_NULL | IS NOT NULL |
BETWEEN | BETWEEN |
NOT_BETWEEN | NOT BETWEEN |
IN | IN |
public boolean updateTable(){
Environment env = Environment.getStandardEnvironment(processData);
Database db = SystemWorkspace.getConnectionsWorkspace().getDatabase("Repository", env);
Table table = RepositoryUtil.getTable("Repository", "Table");
UpdateStatement updTable = new UpdateStatement(table, env.getSessionValues(), env.getDataTypeHandler(), db);
updTable.addColumnValue("CHAMP1", "VALEUR1");
updTable.addColumnValue("CHAMP2", "VALEUR2");
updTable.addWhere("CHAMP1", "VALEUR1");
updTable.addWhere("CHAMP2", "VALEUR2");
updTable.addWhere("CHAMP3", "VALEUR3");
try {
updTable.executeAndClose();
} catch (SQLException e) {
e.printStackTrace();
}
return true;
}