亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? odb.cpp

?? 用C語(yǔ)言寫的一個(gè)數(shù)據(jù)庫(kù)
?? CPP
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
// Odb.cpp
//
// Release 1, Copyright (C) 1999 Ben Bryant
// This is sample source code, nothing more is implied. Use it only as such.
// This software is provided 'as-is', without warranty. In no event will the
// author be held liable for any damages arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose.
// The origin of this software must not be misrepresented; you must not claim
// that you wrote the original software. Altered source versions must be plainly
// marked as such, and must not be misrepresented as being the original software.
// Ben Bryant bcbryant@firstobject.com

#include "stdafx.h"
#include "Odb.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


#define MAXROWS 10


//////////////////////////////////////////////////////////////////
// Oracle Call Interface (OCI) Wrapper
//
#ifdef __STDC__
#include <oci.h>
#else
#define __STDC__ 1
#include <oci.h>
#undef __STDC__
#endif

//////////////////////////////////////////////////////////////////////
// COdb::OdbField
//////////////////////////////////////////////////////////////////////

struct COdb::OdbField
{
	//
	// This structure maintains an OCI field/column/variable
	//
	CString csName;
	dvoid* pBuffer;
	ub2 wType;
	ub2 wSize;
	ub2 wLen;
	sb2 nInd;
	BOOL bQuotedOnUpdate;

	// Methods
	OdbField();
	~OdbField();
	void SetSize( ub2 w );
	void Set( CString cs );
	CString Get() const;
	CString GetMultiRow( int Row ) const;
	void Free();
};

COdb::OdbField::OdbField()
{
	pBuffer = NULL;
	wType = SQLT_STR;
	wSize = 0;
	wLen = 0;
	nInd = 0;
	bQuotedOnUpdate = TRUE;
}

COdb::OdbField::~OdbField()
{
	Free();
}

void COdb::OdbField::SetSize( ub2 w )
{
	//
	// Make sure buffer is at least size w
	//
	if ( w > wSize || ! pBuffer )
	{
		Free();
		pBuffer = (dvoid*) new char[w*MAXROWS];
		wSize = w;
	}
}

void COdb::OdbField::Set( CString cs )
{
	//
	// Set buffer to hold CString
	//
	wLen = cs.GetLength() + 1;
	SetSize( wLen );
	strcpy( (char*)pBuffer, cs );
}

CString COdb::OdbField::Get() const
{
	//
	// All fields are converted to strings by the OCI
	// because SQLT_STR and SQLT_LNG are specified when binding fields
	// Copy from buffer into a string
	//
	CString csResult;
	csResult.Format("%.*s", wLen, (const char*)pBuffer);
	csResult.TrimRight();
	return csResult;
}

CString COdb::OdbField::GetMultiRow( int Row ) const
{
	//
	// All fields are converted to strings by the OCI
	// because SQLT_STR and SQLT_LNG are specified when binding fields
	// Copy from buffer into a string
	//

	/* should test !! */
	CString csResult;
	csResult.Format("%.*s", wLen, (const char*)pBuffer+Row*wSize);
	csResult.TrimRight();
	return csResult;
}

void COdb::OdbField::Free()
{
	//
	// Free field's allocated buffer
	//
	if ( pBuffer )
	{
		delete pBuffer;
		pBuffer = NULL;
	}
}

//////////////////////////////////////////////////////////////////////
// COdb::OdbRecordSet
//////////////////////////////////////////////////////////////////////

struct COdb::OdbRecordSet
{
	//
	// This structure maintains a recordset
	// A recordset holds a row of select results
	//
	CPtrArray paFields;
	int m_nRows;
	CString m_csStatement;

	// Methods
	OdbRecordSet();
	~OdbRecordSet();
	int Find( const CString& csName );
	void RemoveAll();
};

COdb::OdbRecordSet::OdbRecordSet()
{
}

COdb::OdbRecordSet::~OdbRecordSet()
{
	RemoveAll();
}

void COdb::OdbRecordSet::RemoveAll()
{
	//
	// Remove fields
	//
	for ( int iField=0; iField<paFields.GetSize(); ++iField )
		delete (OdbField*)paFields[iField];
	paFields.RemoveAll();
}

int COdb::OdbRecordSet::Find( const CString& csName )
{
	//
	// Return iField or -1 if name not found
	//
	for ( int iField=0; iField<paFields.GetSize(); ++iField )
	{
		OdbField* pField = (OdbField*)paFields.GetAt( iField );
		if ( pField->csName == csName )
			return iField;
	}
	return -1;
}

//////////////////////////////////////////////////////////////////////
// OdbContext
//////////////////////////////////////////////////////////////////////

struct COdb::OdbContext
{
	//
	// This structure maintains all of the OCI variables
	// It is declared here rather than in the header
	// to isolate OCI from COdb clients
	//
	OdbContext();
	void Clear();
	char szError[512];
	HRESULT hr;
	OCIEnv* hpEnv;
	OCIServer* hpServer;
	OCIError* hpErr;
	OCISvcCtx* hpContext;
	OCIStmt *hpSelect;
	OdbRecordSet rsSelect;

	/* add by lf */
	OCIStmt *hpStatement;
};

COdb::OdbContext::OdbContext()
{
	Clear();
}

void COdb::OdbContext::Clear()
{
	hr = OCI_SUCCESS;
	hpEnv = NULL;
	hpErr = NULL;
	hpServer = NULL;
	hpContext = NULL;
	hpSelect = NULL;
	szError[0] = '\0';

	hpStatement = NULL;
}

//////////////////////////////////////////////////////////////////////
// COdb
//////////////////////////////////////////////////////////////////////

COdb::COdb()
{
	m_po = new OdbContext;
	TRACE("\n ODB initialize OK!");
}

COdb::~COdb()
{
	Close();
	delete m_po;
	TRACE("\n ODB exit!");
}

void COdb::CheckErr( short status )
{
	//
	// This sets the OCI error string
	// Later, this might be made to generate an exception
	// The table of codes and strings is kept here in a static array
	//
	static struct CErrorPair
	{
		sword w;
		const char* szText;
	}
		epaErrors[] =
	{
		OCI_SUCCESS,			"SUCCESS",
		OCI_SUCCESS_WITH_INFO,	"SUCCESS_WITH_INFO",
		OCI_NEED_DATA,			"NEED_DATA",
		OCI_NO_DATA,			"NO_DATA",
		OCI_INVALID_HANDLE,		"INVALID_HANDLE",
		OCI_STILL_EXECUTING,	"STILL_EXECUTE",
		OCI_CONTINUE,			"CONTINUE",
	};

	// Check status
	m_po->hr = status;
	if ( m_po->hr == OCI_ERROR )
	{
		// for the special case OCI_ERROR, call OCIErrorGet for the string
		sb4 errcode = 0;
	    OCIErrorGet(m_po->hpErr, 1, NULL, &errcode, 
			(unsigned char*)m_po->szError, sizeof(m_po->szError), OCI_HTYPE_ERROR);
	}
	else
	{
		// Look for description in static array
		DWORD nTotalResultCodes = sizeof(epaErrors) / sizeof(CErrorPair);
		for ( int iPos = 0; iPos < sizeof(epaErrors); ++ iPos )
		{
			if ( epaErrors[iPos].w == m_po->hr )
			{
				strcpy( m_po->szError, epaErrors[iPos].szText );
				break;
			}
		}
	}
}

CString COdb::GetErrorDescription()
{
	return m_po->szError;
}

HRESULT COdb::Open( const CString csConnect )
{
	//
	// This opens a connection with the database
	// Connect string format is user/password@host
	//
	CString csUser, csPassword, csServer;
	int iSlash = csConnect.Find("/");
	if ( iSlash > -1 )
	{
		csUser = csConnect.Left(iSlash);
		csPassword = csConnect.Mid(iSlash + 1);
		int iAt = csConnect.Find("@");
		if ( iAt > iSlash )
		{
			csPassword = csConnect.Mid( iSlash + 1, iAt - iSlash - 1 );
			csServer = csConnect.Mid(iAt + 1);
		}
	}
	else
	{
		csUser = csConnect;
	}
	if ( csUser.IsEmpty() && csPassword.IsEmpty() )
	{
		// For default OS logon, specify slash for user name and password
		csUser = "/";
		csPassword = "/";
	}

	// First, we make sure its closed
	Close();

	// Initialize OCI DLL specifying the mode
	CheckErr( OCIInitialize( OCI_OBJECT, NULL, NULL, NULL, NULL ) );
	if ( FAILED(m_po->hr) )
		return m_po->hr;

	// Note an alternative is to use the OCILogon/Logoff functions
	// Here we allocate all of the handles explicitly
	// Initialize the environment handle
	CheckErr( OCIEnvInit( &m_po->hpEnv, OCI_DEFAULT, 0, NULL ) );
	if ( FAILED(m_po->hr) )
		return m_po->hr;

	// Allocate error, server, and service context handles
	OCIHandleAlloc( m_po->hpEnv, (void**)&m_po->hpErr, OCI_HTYPE_ERROR, 0, NULL );
	OCIHandleAlloc( m_po->hpEnv, (void**)&m_po->hpServer, OCI_HTYPE_SERVER, 0, NULL );
	OCIHandleAlloc( m_po->hpEnv, (void**)&m_po->hpContext, OCI_HTYPE_SVCCTX, 0, NULL );

	// Associate TNS with server handle
	CheckErr( OCIServerAttach( m_po->hpServer,
		m_po->hpErr,
		(unsigned char*)(const char*)csServer,
		csServer.GetLength(),
		0 )
		);
	if ( FAILED(m_po->hr) )
		return m_po->hr;

	// Get server version string
	const nVersionLength = 1024;
	CString csVersion;
	CheckErr( OCIServerVersion( m_po->hpServer,
		m_po->hpErr,
		(text*)csVersion.GetBuffer(nVersionLength),
		nVersionLength,
		OCI_HTYPE_SERVER )
		);
	if ( FAILED(m_po->hr) )
		return m_po->hr;
	csVersion.ReleaseBuffer();
	m_csLog += "\n" + csVersion + "\n";

	// Specify server handle to service context
	CheckErr( OCIAttrSet( m_po->hpContext,
		OCI_HTYPE_SVCCTX,
		m_po->hpServer,
		0,
		OCI_ATTR_SERVER,
		m_po->hpErr )
		);
	if ( FAILED(m_po->hr) )
		return m_po->hr;

	// Allocate a session handle
	OCISession *hpSession = NULL;
	OCIHandleAlloc( m_po->hpEnv, (void**)&hpSession, OCI_HTYPE_SESSION, 0, NULL);

	// Associate username with session handle
	OCIAttrSet( hpSession,
		OCI_HTYPE_SESSION,
		(void*)(const char*)csUser,
		csUser.GetLength(),
		OCI_ATTR_USERNAME,
		m_po->hpErr
		);

	// Associate password with session handle
	OCIAttrSet( hpSession,
		OCI_HTYPE_SESSION,
		(void*)(const char*)csPassword,
		csPassword.GetLength(),
		OCI_ATTR_PASSWORD,
		m_po->hpErr
		);

	// Open session using service context and session handle
	CheckErr( OCISessionBegin( m_po->hpContext,
		m_po->hpErr,
		hpSession,
		OCI_CRED_RDBMS,
		OCI_DEFAULT )
		);
	if ( FAILED(m_po->hr) )
		return m_po->hr;

	// Specify session handle to service context
	OCIAttrSet( m_po->hpContext,
		OCI_HTYPE_SVCCTX,
		hpSession,
		0,
		OCI_ATTR_SESSION,
		m_po->hpErr
		);

	// Change date format
	if ( SUCCEEDED(m_po->hr) )
	{
		CString csSQL = "alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss'";
		m_po->hr = Exec( csSQL );
	}

	/* Alloc OCIHandle, add by lf */
	Exec_Before();

	return m_po->hr;
}

HRESULT COdb::Close()
{
	//
	// This closes and/or cleans up the connection
	// It should work even if the connection is closed or partly open
	//
	m_po->hr = OCI_SUCCESS;

	// Free select statement handle

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩久久久一区| 亚洲日本中文字幕区| 日韩女同互慰一区二区| 欧美老女人在线| 欧美酷刑日本凌虐凌虐| 欧美精品1区2区3区| 欧美一区二区三区四区五区| 91精品久久久久久久99蜜桃| 欧美嫩在线观看| 在线不卡一区二区| 欧美一卡2卡三卡4卡5免费| 欧美日韩国产综合草草| 欧美美女一区二区三区| 欧美久久婷婷综合色| 欧美日本一区二区| 欧美一级片免费看| 精品久久久影院| 日韩久久精品一区| 亚洲精品在线三区| 精品久久久久久久久久久久包黑料| 91精品国产欧美日韩| 欧美人妇做爰xxxⅹ性高电影| 欧美午夜不卡视频| 欧美乱妇一区二区三区不卡视频| 欧美精品久久99| av网站免费线看精品| 成人精品免费网站| 在线观看成人免费视频| 欧美日韩中文字幕一区二区| 欧美日本在线观看| 欧美电视剧在线看免费| 久久免费视频一区| 国产精品丝袜久久久久久app| 国产精品国模大尺度视频| 亚洲人一二三区| 亚洲一区二区三区四区五区黄| 亚洲国产精品欧美一二99| 蜜桃视频在线观看一区| 国产在线看一区| 99久久久无码国产精品| 久久综合久久鬼色中文字| 精品国产一区二区三区四区四| 国产午夜精品福利| 亚洲欧美激情插| 爽好多水快深点欧美视频| 精品在线一区二区| 99久久精品国产毛片| 欧美日韩在线直播| 精品精品欲导航| 国产精品视频在线看| 午夜激情综合网| 国内精品国产成人国产三级粉色| 成人性生交大片免费看视频在线 | 一区二区三区四区av| 亚洲成av人片在线| 国产毛片精品国产一区二区三区| 国产+成+人+亚洲欧洲自线| 欧亚洲嫩模精品一区三区| 日韩免费观看高清完整版在线观看| 久久精品综合网| 亚洲精品乱码久久久久久黑人| 日韩电影一区二区三区| 国产精品亚洲第一区在线暖暖韩国| 91美女在线观看| 日韩欧美激情四射| 最好看的中文字幕久久| 青青草视频一区| 99精品在线免费| 欧美mv日韩mv| 亚洲一区在线观看免费| 免费观看一级特黄欧美大片| 国产91高潮流白浆在线麻豆 | 久久伊99综合婷婷久久伊| 国产精品久久福利| 裸体在线国模精品偷拍| 色香蕉久久蜜桃| 欧美v国产在线一区二区三区| 亚洲男同1069视频| 国产一区二区导航在线播放| 日本韩国一区二区三区视频| 精品精品欲导航| 午夜亚洲国产au精品一区二区| 日av在线不卡| 欧美日韩亚洲综合在线| 国产精品久久久久久久浪潮网站| 美女精品一区二区| 欧美亚洲尤物久久| 国产精品私人自拍| 激情偷乱视频一区二区三区| 欧美日韩激情在线| 国产精品美女久久久久久久久久久| 六月丁香婷婷久久| 99精品一区二区三区| 2020国产精品| 欧美bbbbb| 欧美体内she精高潮| 亚洲日本丝袜连裤袜办公室| 成人国产在线观看| 欧美一区二区三区在线看| 亚洲午夜精品在线| 日本道色综合久久| 1000精品久久久久久久久| 国产一区视频在线看| 日韩一级片在线播放| 亚洲成av人综合在线观看| 91麻豆免费看| 国产精品高潮呻吟久久| 国产高清视频一区| 久久精品夜色噜噜亚洲aⅴ| 久久精品国产在热久久| 在线播放欧美女士性生活| 午夜精品一区在线观看| 日本二三区不卡| 亚洲特级片在线| 成人a免费在线看| 欧美高清在线一区| 国产成人a级片| 国产色爱av资源综合区| 激情欧美一区二区| 久久久精品日韩欧美| 裸体健美xxxx欧美裸体表演| 日韩午夜激情av| 经典三级视频一区| 2020国产精品| 福利一区福利二区| 国产精品国产三级国产aⅴ原创| 成人精品视频一区二区三区尤物| 国产丝袜美腿一区二区三区| 成人av电影在线| 亚洲美女少妇撒尿| 欧美专区亚洲专区| 天堂va蜜桃一区二区三区漫画版| 制服丝袜亚洲色图| 秋霞av亚洲一区二区三| 日韩西西人体444www| 精品一区二区三区视频 | 欧美国产日韩在线观看| 国产不卡在线视频| 亚洲女厕所小便bbb| 在线视频你懂得一区| www.欧美日韩国产在线| 国产精品久久久久三级| 在线精品国精品国产尤物884a| 亚洲综合精品久久| 日韩精品综合一本久道在线视频| 国产精品99久久久久久久vr| 欧美国产精品一区| 色女孩综合影院| 日韩中文字幕区一区有砖一区 | 国产精选一区二区三区| 国产精品免费久久久久| 欧美亚洲国产bt| 亚洲一二三四在线| 国产无人区一区二区三区| 一本久久综合亚洲鲁鲁五月天 | 亚洲乱码国产乱码精品精98午夜| 欧美日韩一区二区三区四区五区 | 亚洲免费观看高清| 欧美一区二区三区四区在线观看 | 日本一区二区三区四区 | 国产精品影音先锋| 国产精品免费人成网站| 91精品国产色综合久久不卡电影 | 一区二区三区欧美在线观看| 欧美区视频在线观看| 国产一二精品视频| 亚洲男人都懂的| 精品国产1区二区| 成人蜜臀av电影| 亚洲黄一区二区三区| 精品久久久影院| 91亚洲精品久久久蜜桃网站 | 成a人片国产精品| 色哟哟亚洲精品| 欧美日韩亚洲综合一区二区三区| 日本黄色一区二区| 精品裸体舞一区二区三区| 91精品国模一区二区三区| 亚洲一区二区av电影| 色呦呦国产精品| 国产成人一级电影| 极品瑜伽女神91| 免费在线欧美视频| 国产精品萝li| 99久久婷婷国产精品综合| 日韩欧美专区在线| 一区二区三区成人| 日韩成人精品在线| 色欲综合视频天天天| 欧美成人高清电影在线| 日韩美女啊v在线免费观看| 日韩一区精品视频| 成人网在线播放| 日韩午夜在线观看| 亚洲大型综合色站| 99久久99久久免费精品蜜臀| 日韩美女精品在线| 美国三级日本三级久久99| 粉嫩高潮美女一区二区三区| 日韩美一区二区三区|