Modifying Structure Tables
Contents
Inserting or Modifying Rows
JChem provides the
chemaxon.jchem.db.UpdateHandler
class for updating and inserting rows in structure tables.
A structure table contains
fix columns
(cd_...) and, optionally,
additional columns that have been defined explicitly.
Java example:
ConnectionHandler conh;
int id; // cd_id value of compound
// Additional columns:
String name;
Float stock;
String comments;
...
UpdateHandler uh = new UpdateHandler(conh,
(isInsertion?
UpdateHandler.INSERT :
UpdateHandler.UPDATE),
structureTableName, "name, stock, comments");
try {
uh.setStructure(molfile);
if(!isInsertion) {
uh.setID(id);
}
uh.setValueForAdditionalColumn(1, name);
uh.setValueForAdditionalColumn(2, stock);
uh.setValueForAdditionalColumn(3, comments);
uh.execute();
} finally {
uh.close();
}
...
More examples:
- JSP:
<JChem's home>/examples/db_search/update.jsp - ASP:
<JChem's home>\examples\asp\update.asp
Deleting Rows
The deleteRows method of the
UpdateHandler class is suggested for
deleting rows from structure tables. It also increments
updateCounter for the given table in
JChemProperties, which is important when
caching is used during structure search.
Example:
UpdateHandler.deleteRows(conh, structureTableName,
"WHERE cd_id>1000");
Other Methods
Other useful methods of
UpdateHandler:
| getStructureTables | Retrieves the name of all structure tables. |
| createStructureTable | Creates a structure table. |
| dropStructureTable | Removes a structure table. |
Do you have a question? Would you like to learn more? Please browse among the related topics on our support forum or search the website. If you want to suggest modifications or improvements to our documentation email our support directly!
