diff options
author | deva <deva> | 2009-07-17 13:02:45 +0000 |
---|---|---|
committer | deva <deva> | 2009-07-17 13:02:45 +0000 |
commit | 177cea995d02fd14dd82fa010957ebfbc1c5e760 (patch) | |
tree | 62703ddc11b83a054e8068c0e9c79ce1951959a6 /server/src/pracrodaopgsql.cc | |
parent | a619ccc300a00947207600e11fac848b7d37b26b (diff) |
More work on the macrotool. Now fieldnames can be added and deleted, and a filehandler is able to add new macros assuring no conflicts in macro names/version/filenames happen. Error messages in MacroParser has been made more elaborate.
Diffstat (limited to 'server/src/pracrodaopgsql.cc')
-rw-r--r-- | server/src/pracrodaopgsql.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/server/src/pracrodaopgsql.cc b/server/src/pracrodaopgsql.cc index 683fe85..7159b03 100644 --- a/server/src/pracrodaopgsql.cc +++ b/server/src/pracrodaopgsql.cc @@ -244,10 +244,37 @@ unsigned PracroDAOPgsql::nrOfCommits(std::string patientid, std::string macronam void PracroDAOPgsql::addFieldname(std::string name, std::string description) { + std::stringstream timestamp; timestamp << time(NULL); + std::string ts; + try { + pqxx::work W(*conn); + ts = "INSERT INTO fieldnames (name, description, \"timestamp\") VALUES (" + " '" + W.esc(name) + "', " + " '" + W.esc(description) + "', " + " '" + W.esc(timestamp.str()) + "' " + ")" + ; + PRACRO_DEBUG(sql, "Query: %s\n", ts.c_str()); + pqxx::result R = W.exec(ts); + W.commit(); + } catch (std::exception &e) { + PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str()); + } } void PracroDAOPgsql::delFieldname(std::string name) { + std::string ts; + try { + pqxx::work W(*conn); + ts = "DELETE FROM fieldnames WHERE name=" + "'" + W.esc(name) + "' "; + PRACRO_DEBUG(sql, "Query: %s\n", ts.c_str()); + pqxx::result R = W.exec(ts); + W.commit(); + } catch (std::exception &e) { + PRACRO_ERR_LOG(db, "Query failed: %s: %s\n", e.what(), ts.c_str()); + } } std::vector<Fieldname> PracroDAOPgsql::getFieldnames() |