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

📄 sqlapi.h

📁 SQLAPI C/C++ 连接Oracle 数据库!
💻 H
📖 第 1 页 / 共 3 页
字号:
#else	// !SA_UNICODE#define GetMultiByteChars operator const SAChar *#define GetMultiByteCharsLength GetLength	// return pointer to const Unicode string, convert if needed	const wchar_t *GetWideChars() const;	// get string length (in Unicode characters)	int GetWideCharsLength() const;#endif	// !SA_UNICODE// Implementationpublic:	~SAString();protected:	SAChar *m_pchData;	// pointer to ref counted string data	// implementation helpers	SAStringData *GetData() const;	void Init();	void AllocBuffer(int nLen);#ifdef SA_UNICODE	void AssignBinaryCopy(int nSrcLenInBytes, const void *pSrcData);	void ConcatBinaryCopy(int nSrc1LenInBytes, const void *pSrc1Data, int nSrc2LenInBytes, const void *pSrc2Data);	void ConcatBinaryInPlace(int nSrcLen, const void *pData);#endif	// SA_UNICODE	void AssignCopy(int nSrcLen, const SAChar *lpszSrcData);	void ConcatCopy(int nSrc1Len, const SAChar *lpszSrc1Data, int nSrc2Len, const SAChar *lpszSrc2Data);	void ConcatInPlace(int nSrcLen, const SAChar *lpszSrcData);	void CopyBeforeWrite();	void AllocBeforeWrite(int nLen);	void Release();	static void Release(SAStringData *pData);	static int SafeStrlen(const SAChar *lpsz);	static void FreeData(SAStringData *pData);};// Compare helpersbool SQLAPI_API operator==(const SAString &s1, const SAString &s2);bool SQLAPI_API operator==(const SAString &s1, const SAChar *s2);bool SQLAPI_API operator==(const SAChar *s1, const SAString &s2);bool SQLAPI_API operator!=(const SAString &s1, const SAString &s2);bool SQLAPI_API operator!=(const SAString &s1, const SAChar *s2);bool SQLAPI_API operator!=(const SAChar *s1, const SAString &s2);bool SQLAPI_API operator<(const SAString &s1, const SAString &s2);bool SQLAPI_API operator<(const SAString &s1, const SAChar *s2);bool SQLAPI_API operator<(const SAChar *s1, const SAString &s2);bool SQLAPI_API operator>(const SAString &s1, const SAString &s2);bool SQLAPI_API operator>(const SAString &s1, const SAChar *s2);bool SQLAPI_API operator>(const SAChar *s1, const SAString &s2);bool SQLAPI_API operator<=(const SAString &s1, const SAString &s2);bool SQLAPI_API operator<=(const SAString &s1, const SAChar *s2);bool SQLAPI_API operator<=(const SAChar *s1, const SAString &s2);bool SQLAPI_API operator>=(const SAString &s1, const SAString &s2);bool SQLAPI_API operator>=(const SAString &s1, const SAChar *s2);bool SQLAPI_API operator>=(const SAChar *s1, const SAString &s2);class SQLAPI_API SANull{};#define SA_NUMERIC_MANTISSA_SIZE 32class SQLAPI_API SANumeric{	void InitZero();	void setFromPlainString(const SAChar *sVal);	void setFromExpString(const SAString &sVal);public:	SANumeric();	// default constructor, initializes to zero	SANumeric(double dVal);			// initializes from double	SANumeric &operator=(double);	// reinitializes from double	operator double() const;		// converts to double	SANumeric(sa_int64_t iVal);			// initializes from 64-bit integer	SANumeric(sa_uint64_t iVal);	SANumeric &operator=(sa_int64_t);	// reinitializes from 64-bit integer	SANumeric &operator=(sa_uint64_t);	operator sa_int64_t() const;		// converts to 64-bit integer	operator sa_uint64_t() const;	SANumeric &operator=(const SAChar *sVal);	// reinitializes from string	operator SAString() const;	// converts to stringpublic:	unsigned char precision;	// the maximum number of digits in base 10	unsigned char scale;		// the number of digits to the right of the decimal point	unsigned char sign;			// the sign: 1 for positive numbers, 0 for negative numbers	// a number stored as SA_NUMERIC_MANTISSA_SIZE-byte scaled integer, with the least-significant byte on the left	unsigned char val[SA_NUMERIC_MANTISSA_SIZE];};class SQLAPI_API SAInterval{public:	SAInterval();	SAInterval(double dVal);	SAInterval(long nDays, int nHours, int nMins, int nSecs);	double GetTotalDays() const;	double GetTotalHours() const;	double GetTotalMinutes() const;	double GetTotalSeconds() const;	long GetDays() const;	long GetHours() const;	long GetMinutes() const;	long GetSeconds() const;	SAInterval& operator=(double dVal);	SAInterval operator+(const SAInterval& interval) const;	SAInterval operator-(const SAInterval& interval) const;	SAInterval& operator+=(const SAInterval interval);	SAInterval& operator-=(const SAInterval interval);	SAInterval operator-() const;	operator double() const;	operator SAString() const;	void SetInterval(long nDays, int nHours, int nMins, int nSecs);private:	double m_interval;};//! Provides support for manipulating date/time valuesclass SQLAPI_API SADateTime{	static int m_saMonthDays[13];protected:	static bool DateFromTm(		unsigned short wYear, unsigned short wMonth, unsigned short wDay,		unsigned short wHour, unsigned short wMinute, unsigned short wSecond,		unsigned long nNanoSecond,		double &dtDest);	static bool TmFromDate(		double dtSrc,		struct tm &tmDest, unsigned long &nNanoSecond);protected:	void Init_Tm();	struct tm m_tm;	unsigned long m_nFraction;	// 0..999999999	int	nReserved;public:	SADateTime();	SADateTime(const SADateTime &other);	SADateTime(const struct tm &tmValue);	SADateTime(const struct timeb &tmbValue);	SADateTime(const struct timeval &tmvValue);	operator struct tm &();	operator struct tm() const;	SADateTime(double dt);	operator double() const;	operator SAString() const;	SADateTime(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec);	int GetYear() const;		// year, f.ex., 1999, 2000	int GetMonth() const;		// 1..12	int GetDay() const;			// 1..31	int GetHour() const;		// 0..23	int GetMinute() const;		// 0..59	int GetSecond() const;		// 0..59	int GetDayOfWeek() const;	// 1..7, 1=Sunday, 2=Monday, and so on	int GetDayOfYear() const;	// 1..366, where January 1 = 1	unsigned long &Fraction();	unsigned long Fraction() const;	void GetTimeValue(struct timeb &tmv);	void GetTimeValue(struct timeval &tmv);	//! Return the current date/time value	static SADateTime SQLAPI_CALLBACK currentDateTime();	static SADateTime SQLAPI_CALLBACK currentDateTimeWithFraction();	SADateTime operator+(SAInterval interval) const;	SADateTime operator-(SAInterval interval) const;	SADateTime& operator+=(SAInterval interval);	SADateTime& operator-=(SAInterval interval);	SAInterval operator-(const SADateTime& dt) const;};class SQLAPI_API SAPos{	friend class SACommand;	SAString m_sName;public:	SAPos(int nByID);	SAPos(const SAString& sByName);};class SQLAPI_API saOptions{	int		m_nOptionCount;	SAParam	**m_ppOptions;private:	// disable copy constructor	saOptions(const saOptions &);	// disable assignment operator	saOptions &operator = (const saOptions &);public:	saOptions();	virtual ~saOptions();	SAString &operator[](const SAString &sOptionName);	SAString operator[](const SAString &sOptionName) const;};//! Represents an unique session with a data sourceclass SQLAPI_API SAConnection{	friend class SACommand;	friend class SAField;	friend class SAParam;	friend class ISAConnection;	friend class Iora7Connection;	friend class Iora8Connection;private:	// disable copy constructor	SAConnection(const SAConnection &);	// disable assignment operator	SAConnection &operator = (const SAConnection &);	SAClient_t m_eSAClient;	ISAConnection *m_pISAConnection;	SAMutex *m_pCommandsMutex;	sa_Commands *m_pCommands;	SAIsolationLevel_t m_eIsolationLevel;	SAAutoCommit_t m_eAutoCommit;	saOptions m_Options;	int	nReserved;protected:	void EnumCursors(EnumCursors_t fn, void *pAddlData);	void RegisterCommand(SACommand *pCommand);	void UnRegisterCommand(SACommand *pCommand);	ISACursor *GetISACursor(SACommand *pCommand);public:	SAConnection();	virtual ~SAConnection();	void setClient(SAClient_t eSAClient) SQLAPI_THROW(SAException);	SAClient_t Client() const;	long ClientVersion() const SQLAPI_THROW(SAException);	long ServerVersion() const SQLAPI_THROW(SAException);	SAString ServerVersionString() const SQLAPI_THROW(SAException);	bool isConnected() const;	bool isAlive() const;	void Connect(		const SAString &sDBString,		const SAString &sUserID,		const SAString &sPassword,		SAClient_t eSAClient = SA_Client_NotSpecified,		saConnectionHandler_t fHandler = NULL) SQLAPI_THROW(SAException);	void Disconnect() SQLAPI_THROW(SAException);	void Destroy();	void setIsolationLevel(SAIsolationLevel_t eIsolationLevel) SQLAPI_THROW(SAException);	SAIsolationLevel_t IsolationLevel() const;	void setAutoCommit(SAAutoCommit_t eAutoCommit) SQLAPI_THROW(SAException);	SAAutoCommit_t AutoCommit() const;	void Commit() SQLAPI_THROW(SAException);	void Rollback() SQLAPI_THROW(SAException);	SAString &setOption(const SAString &sOptionName);	SAString Option(const SAString &sOptionName) const;	saAPI *NativeAPI() const SQLAPI_THROW(SAException);	saConnectionHandles *NativeHandles() SQLAPI_THROW(SAException);};// SAConnection options (common for at least several DBMS-es)// Worksattion ID#define SACON_OPTION_WSID		_TSA("WSID")// Application Name#define SACON_OPTION_APPNAME	_TSA("APPNAME")//! Defines a specific command that you intend to execute against a data source.class SQLAPI_API SACommand{	friend class SAConnection;	friend class IibCursor;	friend class IsybCursor;	friend class IssDBLibCursor;	friend class IsbCursor;	friend class ImyCursor;	friend class IpgCursor;	friend class Iora8Connection;	friend class Iora8Cursor;	friend class Iora7Connection;	friend class Iora7Cursor;private:	// disable copy constructor	SACommand(const SACommand &);	// disable assignment operator	SACommand &operator = (const SACommand &);	SAConnection	*m_pConnection;	SACommandType_t	m_eCmdType;	SAString		m_sCmd;	bool			m_bPrepared;	bool			m_bExecuted;	bool			m_bFieldsDescribed;	bool			m_bSelectBuffersSet;	bool			m_bParamsKnown;	int				m_nPlaceHolderCount;	saPlaceHolder	**m_ppPlaceHolders;	int				m_nParamCount;	SAParam			**m_ppParams;	int				m_nCurParamID;	SAString		m_sCurParamName;		int				m_nFieldCount;	SAField			**m_ppFields;	saOptions		m_Options;	int	nReserved;	void Init();	static int CompareIdentifier(		const SAString &sIdentifier1,		const SAString &sIdentifier2);	SAParam &CreateParam(		const SAString &sName,		SADataType_t eParamType,		int nNativeType,		int nParamSize,		int	nParamPrecision,		int	nParamScale,		SAParamDirType_t eDirType,		const SAString &sFullName,		int nStart,	// param position in SQL statement		int nEnd);	// param end position in SQL statemen	void GetParamsSP();	void UnDescribeParams();	void ParseInputMarkers(		SAString &sCmd,		bool *pbSpacesInCmd);	void DescribeFields() SQLAPI_THROW(SAException);	void CreateField(		const SAString &sName,		SADataType_t eFieldType,		int nNativeType,		long nFieldSize,		long nFieldPrecision,		int nFieldScale,		bool bFieldRequired);	void DestroyFields();	// parses sql statement and create bind parameters array if any (In)	// also cancels previous stsement if any	void ParseCmd(		const SAString &sSQL,		SACommandType_t eCmdType);	void UnSetCommandText();	void UnPrepare();	void UnExecute();public:	//! Construct command with no associated connection and SQL	SACommand();	//! Construct command based on the given connection and SQL	SACommand(		SAConnection *pConnection,		const SAString &sCmd = SAString(),		SACommandType_t eCmdType = SA_CmdUnknown);		virtual ~SACommand();	SAConnection *Connection() const;	void setConnection(SAConnection *pConnection);	virtual void Open() SQLAPI_THROW(SAException);	virtual bool isOpened();	virtual bool isExecuted();	virtual void Close() SQLAPI_THROW(SAException);	virtual void Destroy();	void setCommandText(		const SAString &sSQL,		SACommandType_t eCmdType = SA_CmdUnknown);	SAString CommandText() const;	SACommandType_t CommandType() const;	virtual void Prepare() SQLAPI_THROW(SAException);	virtual void Execute() SQLAPI_THROW(SAException);	bool isResultSet() SQLAPI_THROW(SAException);	long RowsAffected() SQLAPI_THROW(SAException);	// returns number of rows affected by last DML operation	bool FetchNext() SQLAPI_THROW(SAException);	// returns true if new row is fetched#ifdef SQLAPI_SCROLLABLE_CURSOR	bool FetchPrior() SQLAPI_THROW(SAException);	bool FetchFirst() SQLAPI_THROW(SAException);	bool FetchLast() SQLAPI_THROW(SAException);#endif // SQLAPI_SCROLLABLE_CURSOR	void Cancel() SQLAPI_THROW(SAException);	SAParam &CreateParam(		const SAString &sName,		SADataType_t eParamType,		SAParamDirType_t eDirType = SA_ParamInput);	SAParam &CreateParam(		const SAString &sName,		SADataType_t eParamType,		int nNativeType,		int nParamSize,		int	nParamPrecision,		int	nParamScale,		SAParamDirType_t eDirType);	void DestroyParams();	int ParamCount();	SAParam &ParamByIndex(int i);	// zero based index of C array	SAParam &Param(int nParamByID);	// id in SQL statement, not in C array	SAParam &Param(const SAString& sParamByName);	SACommand &operator << (const SAPos &pos);	SACommand &operator << (const SANull &null);	SACommand &operator << (bool Value);	SACommand &operator << (short Value);	SACommand &operator << (unsigned short Value);	SACommand &operator << (long Value);	SACommand &operator << (unsigned long Value);	SACommand &operator << (double Value);	SACommand &operator << (const SANumeric &Value);	SACommand &operator << (const SADateTime &Value);	SACommand &operator << (const SAChar *Value);	// special overload for string constants	SACommand &operator << (const SAString &Value);	SACommand &operator << (const SABytes &Value);	SACommand &operator << (const SALongBinary &Value);	SACommand &operator << (const SALongChar &Value);	SACommand &operator << (const SABLob &Value);	SACommand &operator << (const SACLob &Value);	SACommand &operator << (const SAValueRead &Value);	int FieldCount() SQLAPI_THROW(SAException);	SAField &Field(int nField) SQLAPI_THROW(SAException);	// 1-based field number in result set	SAField &Field(const SAString &sField) SQLAPI_THROW(SAException);	SAField &operator[](int nField) SQLAPI_THROW(SAException);	// 1-based field number in result set	SAField &operator[](const SAString &sField) SQLAPI_THROW(SAException);	SAString &setOption(const SAString &sOptionName);	SAString Option(const SAString &sOptionName) const;	saCommandHandles *NativeHandles() SQLAPI_THROW(SAException);	void setBatchExceptionPreHandler(PreHandleException_t fnHandler);};// SACommand options (common for at least several DBMS-es)// Prefertching rows#define SACMD_PREFETCH_ROWS		_TSA("PreFetchRows")class SQLAPI_API SAValueRead{	friend class ISACursor;	friend class IibCursor;	friend class Iora7Cursor;	friend class Iora8Cursor;	friend class IsbCursor;	friend class IodbcCursor;	friend class IssDBLibCursor;	friend class IssOleDbCursor;	friend class Idb2Cursor;	friend class IinfCursor;	friend class IsybCursor;	friend class ImyCursor;	friend class IpgCursor;	friend class Isl3Cursor;protected:	SALongOrLobReaderModes_t m_eReaderMode;		saLongOrLobReader_t	m_fnReader;	unsigned int	m_nReaderWantedPieceSize;

⌨️ 快捷键说明

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