56 lines
1.4 KiB
C
56 lines
1.4 KiB
C
|
|
#ifndef _DB_MAG_H
|
|||
|
|
#define _DB_MAG_H
|
|||
|
|
|
|||
|
|
#include <string.h>
|
|||
|
|
#include <string>
|
|||
|
|
#include <vector>
|
|||
|
|
#include <iDA/iDA.h>
|
|||
|
|
#include <log4cplus/LOG.h>
|
|||
|
|
#include <dao/DbStandardDBAX.h>
|
|||
|
|
|
|||
|
|
using namespace iPlature;
|
|||
|
|
using namespace baosight;
|
|||
|
|
|
|||
|
|
class DBMag
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
DBMag();
|
|||
|
|
virtual ~DBMag();
|
|||
|
|
private:
|
|||
|
|
static iDA::Command cmd;
|
|||
|
|
|
|||
|
|
public:
|
|||
|
|
|
|||
|
|
//获取SEQUENCE的nextval
|
|||
|
|
static long GetSeqNext(string sequence);
|
|||
|
|
|
|||
|
|
//获取表中某数字字段的最大值
|
|||
|
|
static long GetMaxValue(const string& table, const string& column);
|
|||
|
|
|
|||
|
|
//统计(平均,最大,最小)
|
|||
|
|
//返回到值data[0]平均,data[1]最大,data[2]最小
|
|||
|
|
static short Avg(const string& field,const string& table, const string& where, float values[3]);
|
|||
|
|
|
|||
|
|
//统计多个字段的(平均,最大,最小)
|
|||
|
|
static short Avg(const vector<string> fields,const string& table, const string& where, vector<float>& values);
|
|||
|
|
|
|||
|
|
//求和
|
|||
|
|
static short Sum(const vector<string> fields,const string& table, const string& where, vector<float>& values);
|
|||
|
|
|
|||
|
|
//执行拼装完整的SQL语句
|
|||
|
|
static short Execute(const string& sql , long* count);
|
|||
|
|
|
|||
|
|
//统计相关数据计录数
|
|||
|
|
static long Count(const string& field,const string& table, const string& where);
|
|||
|
|
|
|||
|
|
//SQL方式读取字段
|
|||
|
|
static short ReadDB(const string& sql,vector<float>& values);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
//错误处理
|
|||
|
|
static short SqlErr(long sqlcode);
|
|||
|
|
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
#endif
|