oracle 查询当年数据_查询ORACLE数据库TOP SQL使用情况

5fdd84663cf3e7226fc6b1042e3a987a.png

使用BOOST和ORACLE::OCCI查询ORACLE数据库TOP SQL使用情况

/topsql.h#ifndef TOPSQL_H#define TOPSQL_H#include#include#include#include "odb.h"

using namespace oracle::occi;using namespace std;class topsql{private:string sqlsnap;ResultSet* ress;bool si_debug;public:topsql(bool& sdebug);void printsnap(string& username,string& pw,string& conns,int days,int instid);void printsnap(string& username,string& pw,string& conns);~topsql();

};#endif //TOPSQL_H//~topsql.h

_____________________

//topsql.cpp#include "topsql.h"#include#include//constractortopsql::topsql(bool& sdebug):si_debug(sdebug),ress(0){if(si_debug){cout }}

void topsql::printsnap(string& username,string& pw,string& conns){printsnap(username,pw,conns,1,1);}

void topsql::printsnap(string& username,string& pw,string& conns,int days=1,int instid=1){if(si_debug){cout }odb odb1;//init sqlsnapstring strdays;string strinitid;stringstream ss;stringstream ss2;ss ss >> strdays;ss2 ss2 >> strinitid;sqlsnap.append("select SNAP_ID,to_char(BEGIN_INTERVAL_TIME, 'yyyy-mm-dd HH24:MI:SS') btime,");sqlsnap.append("to_char(END_INTERVAL_TIME, 'yyyy-mm-dd HH24:MI:SS') etime ");sqlsnap.append("from dba_hist_snapshot where BEGIN_INTERVAL_TIME > sysdate - ");sqlsnap.append(strdays);sqlsnap.append(" and INSTANCE_NUMBER = ");sqlsnap.append(strinitid);sqlsnap.append(" order by SNAP_ID");

if(si_debug){cout cout }

try{if(si_debug){cout }ress=odb1.exeQuary(username,pw,conns,sqlsnap);}catch(SQLException& sq){cout }

cout cout cout

cout cout cout

while( ress->next() ){string snapid = ress->getString(1);string btime = ress->getString(2);string etime = ress->getString(3);

cout cout cout }}

//deconstratortopsql::~topsql(){if(si_debug){cout }}//~topsql.cpp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值