// AmisqlTable.h #ifndef AmiSqlTable_H #define AmiSqlTable_H // Vinay Sambamurthy // June 2004 // // Ami implementation of SqlTable // 'm_error' is set to a nonzero value in case of an invalid query #include "dataset_sql/SqlTable.h" #include "dataset_sql/SelectQuery.h" #include "dataset_sql/InsertQuery.h" #include "dataset_sql/DeleteQuery.h" #include #include namespace dial { class AmiSqlTable : public dset::SqlTable { private: // data std::string m_table; std::string m_project; std::string m_pstep; std::string m_uname; std::string m_passwd; mutable int m_error; bool m_valid; public: // inherited methods // Constructor. AmiSqlTable(std::string params); // Destructor. virtual ~AmiSqlTable(); // Is this a valid table? bool is_valid() const; // Return the error code. int error() const; // Return a string describing an error. std::string error_string(int ecode) const; // Fetch the table schema dset::SqlResult get_schema() const; // Fetch the description of the column holding the modification time. // Blank if there is no such column. std::string modify_time_column() const; // Fetch the description of the column holding the creation time. // Blank if there is no such column. std::string create_time_column() const; // Fetch the total number of rows. // If empty query, return number of rows in entire table // Otherwise, return the number of rows in the result int get_row_count(dset::SelectQuery query = dset::SelectQuery())const; // Fetch the total number of fields/columns. // If empty query, return the number of columns in schema // Otherwise, return the number of columns in the result int get_col_count(dset::SelectQuery query = dset::SelectQuery()) const; // Return the SqlResult after execution of a SELECT SqlQuery. // Argument carries the select clause (column names ) as well // as the constraint; not from clause. dset::SqlResult execute_select_query(const dset::SelectQuery query) const; // Return the status after execution of a INSERT SqlQuery. // Argument carries a row to be inserted. // Returns 0 on success int execute_insert_query(const dset::InsertQuery query); // Return the status after execution of an update query // Update queries are not allowed // Returns 1 always int execute_update_query(dset::InsertQuery iquery, dset::SelectQuery squery); // Return the status after execution of a DELETE SqlQuery. // Argument carries the constraint; not from clause. // Returns 0 on success int execute_delete_query(const dset::DeleteQuery query); }; } // end namespace dial #endif