⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cursor.h

📁 oracle引用库
💻 H
字号:
#ifndef __CURSOR_H_#define __CURSOR_H_#include <iostream>#include <string>
#include <map>

#include "ocicpp.h"#include "OraError.h"#include "OraType.h"#include "OraString.h"#include "OraNumber.h"#include "OraDummy.h"#include "OraLob.h"#include "OraBFile.h"#include "OraDate.h"#include "OraRaw.h"#include "OraLabel.h"#include "OraRowID.h"#include "OraRefCur.h"#include "Lob.h"#include "BFile.h"#include "RowID.h"#define TEST_EXPLICIT_PREFETCH 1000// const std::string default_null_text="<NULL>";#define default_null_text "<NULL>"namespace OCICPP {using std::string;using std::map;	class Cursor {private: /* OCI Defined handles */	OCIEnv		*envhp;	OCISvcCtx	*svchp;	OCIStmt		*stmthp;	OCIParam	*paramd;	OCIError	*errhp;	map<string,OCIBind *> binds; /* map of bindings */private: 	/* All information is in row now */	OraType		**row; /* Contains fetched row.Array of pointers to OraTypes derivative */	sb4			nCols;	ub2			stmtType; /* Statement type as described in table 4-1 OCI Reference */	sword		status;	string		nulltext; /* Text for null fields */		unsigned	fetched; /* 0..prefetchRows */	unsigned	prefetchRows; /* 1.. */	unsigned	curRow;  /* 0..fetched */	unsigned	fetched_all; /* rows fetched from the start */			int			haveResultSet; 	int			canFetch;	int			Initialized;	OCICPP::CursorType cursorType; /* REFCURSOR or NTABLE */	map<string,int> cols_map; /* For get<Type>("colName") methods */public:	Cursor();	Cursor(OCIEnv *,OCISvcCtx *,OCIError *er,int prefetch,OCICPP::CursorType Type=DEFAULT);	void init(OCIEnv *,OCISvcCtx *,OCIError *er,int prefetch,OCICPP::CursorType Type=DEFAULT);	~Cursor();	void drop();	void setPrefetch(unsigned nRows); /* Once for request*/	int prepare(const string &);	void exec();	unsigned int execEx();	void describe();	void define();	void hashHead(); 	void execute(int prefetch=1); /* User's should use this func in most cases 	                   or they can do exec(),describe(),define()	                   by hand	                */	void bind(const string &par,char *buf,int buflen,short *isNull=0);	void bind(const string &par,const string &val,short *isNull=0);	void bind(const string &par,int &val,short *isNull=0);	void bind(const string &par,double &val,short *isNull=0);	void bind(const string &par,RowID &val,short *isNull=0);	void bind(const string &par,Cursor &val,short *isNull=0);	void bind(const string &par,Lob &val,short *isNull=0);	/* fetch returns non zero value if theres another rows */	bool fetch();/* get<Type> methods working with hardcoded cols numbers */		void getStr(int col,string &,bool *isNull=0) const;	void getInt(int col,int &val,bool *isNull=0,const int *null_value=0) const;	void getDouble(int col,double &val,bool *isNull=0,const double *null_value=0) const;	void getStrMon(int col,string &val) const;	void getSec(int col,int &val) const;	void getMin(int col,int &val) const;	void getHour(int col,int &val) const;	void getDay(int col,int &val) const;	void getMonth(int col,int &val) const;	void getYear(int col,int &val) const;	void getCLOB(int col,Lob &) const;	void getBLOB(int col,Lob &) const;	void getFILE(int col,BFile &) const;	void getRowID(int col,RowID &) const;	void getCursor(int col,Cursor &) const;		        inline string getStr(int col,bool *isNull=0) const;        inline int getInt(int col,bool *isNull=0,const int *null_value=0) const;        inline double getDouble(int col,bool *isNull=0,const double *null_value=0) const;		/* get<Type> same but working with attribute name */	void getStr(const string &col,string &val,bool *isNull=0) const;	void getInt(const string &col,int &val,bool *isNull=0,const int *null_value=0) const;	void getDouble(const string &col,double &val,bool *isNull=0,const double *null_value=0) const;	void getStrMon(const string &,string &) const;	void getSec(const string &,int &) const;	void getMin(const string &,int &) const;	void getHour(const string &,int &) const;	void getDay(const string &,int &) const;	void getMonth(const string &,int &) const;				inline int getDay(int col) const;		inline int getMonth(int col) const;		inline int getYear(int col) const;		inline int getHour(int col) const;		inline int getSec(int col) const;		inline int getMin(int col) const;				inline int getDay(const string &col) const;		inline int getMonth(const string &col) const;		inline int getYear(const string &col) const;		inline int getHour(const string &col) const;		inline int getSec(const string &col) const;		inline int getMin(const string &col) const;					void getYear(const string &,int &) const;	void getCLOB(const string &col,Lob &lob) const;	void getBLOB(const string &col,Lob &lob) const;	void getFILE(const string &col,BFile &bfile) const;	void getRowID(const string &col,RowID &rid) const;	void getCursor(const string &col,Cursor &cur) const;	        inline string getStr(const string &col,bool *isNull=0) const;        inline int getInt(const string &col,bool *isNull=0, const int *null_value=0) const;        inline double getDouble(const string &col,bool *isNull=0, const double *null_value=0) const;	/* Some functions to describe select-list */		int getNCols() const;	void getColName(int col,string &) const; 	int getColSize(int col) const;	int getColSize(const string &) const;	int getColType(int col) const;	int getColType(const string &) const;	void getColTypeName(int col,string &) const;	void getColTypeName(const string &,string &) const;	bool isNull(int col) const;	bool isNull(const string &) const;/* Some supplementary functions */	void setNullText(const string &);private:				void newCellByType(OraType **,OCIStmt *,int col);};} // namespace OCICPP#define GET_STR \    std::string s;       \    getStr(col, s, isNull); \    return (s);inline std::string OCICPP::Cursor::getStr(int col,bool *isNull) const{    GET_STR;}inline std::string OCICPP::Cursor::getStr(const std::string &col,bool *isNull) const{    GET_STR;}#undef GET_STR#define GET_INT  \    int n;          \    getInt(col, n, isNull, null_value); \    return (n);inline int OCICPP::Cursor::getInt(int col,bool *isNull, const int *null_value) const{    GET_INT;}inline int OCICPP::Cursor::getInt(const std::string &col,bool *isNull, const int *null_value) const{    GET_INT;}#undef GET_INT#define GET_DOUBLE  \    double d;       \    getDouble(col, d, isNull, null_value); \    return (d);inline double OCICPP::Cursor::getDouble(int col,bool *isNull, const double *null_value) const{    GET_DOUBLE;}inline double OCICPP::Cursor::getDouble(const std::string &col,bool *isNull, const double *null_value) const{    GET_DOUBLE;}#undef GET_DOUBLE#define GET_DAY  \    int d;       \    getDay(col, d); \    return (d);inline int OCICPP::Cursor::getDay(int col) const {	GET_DAY;}inline int OCICPP::Cursor::getDay(const string &col) const {	GET_DAY;}#define GET_MONTH  \    int d;       \    getMonth(col, d); \    return (d);inline int OCICPP::Cursor::getMonth(int col) const {	GET_MONTH;}inline int OCICPP::Cursor::getMonth(const string &col) const {	GET_MONTH;}#define GET_YEAR  \    int d;       \    getYear(col, d); \    return (d);inline int OCICPP::Cursor::getYear(int col) const {	GET_YEAR;}inline int OCICPP::Cursor::getYear(const string &col) const {	GET_YEAR;}#define GET_HOUR  \    int d;       \    getHour(col, d); \    return (d);inline int OCICPP::Cursor::getHour(int col) const {	GET_HOUR;}inline int OCICPP::Cursor::getHour(const string &col) const {	GET_HOUR;}#define GET_SEC  \    int d;       \    getSec(col, d); \    return (d);inline int OCICPP::Cursor::getSec(int col) const {	GET_SEC;}inline int OCICPP::Cursor::getSec(const string &col) const {	GET_SEC;}#define GET_MIN  \    int d;       \    getMin(col, d); \    return (d);inline int OCICPP::Cursor::getMin(int col) const {	GET_MIN;}inline int OCICPP::Cursor::getMin(const string &col) const {	GET_MIN;}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -