/*---------------------------------------------------------------------------
@doc
@module OciCursor.cpp |
This module contains the <c COciCursor> class implementation.
Author: Fabio Angelini
Docs and test: Abbondio Vago
---------------------------------------------------------------------------*/
extern "C"{
#include <ocidem.h>
#include <ociapr.h>
}
#include "OciClassDef.h"
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include "OciException.h"
#include "OciDatabase.h"
#include "OciVariable.h"
#include "OciCursor.h"
/*---------------------------------------------------------------------------
@mfunc Create "cursor" object.
By default, exceptions are allowed to raise.
@parm Can be set to COciException::enabled (default)
or COciException::disabled.
---------------------------------------------------------------------------*/
COciCursor::COciCursor( int exception_enabled )
: m_RowProceddesCount( m_Cda.rpc ),
m_FunctionCode( m_Cda.ft ),
m_ReturnCode( m_Cda.rc ),
m_ParseErrorOffset( m_Cda.peo )
{
// vl = 0;
// vl_len = 0;
m_pDb = NULL;
m_pStmText = NULL;
m_ExceptionEnabled = exception_enabled;
memset( &m_Cda, 0, sizeof(m_Cda) );
}
/*---------------------------------------------------------------------------
@mfunc Create "cursor" object and open cursor via "connect".
@parm Database object
@parm Can be set to COciException::enabled (default)
or COciException::disabled.
---------------------------------------------------------------------------*/
COciCursor::COciCursor( COciDatabase& db, int exception_enabled )
: m_RowProceddesCount( m_Cda.rpc ),
m_FunctionCode( m_Cda.ft ),
m_ReturnCode( m_Cda.rc ),
m_ParseErrorOffset( m_Cda.peo )
{
// vl = 0;
// vl_len = 0;
m_pDb = &db;
m_pStmText = NULL;
m_ExceptionEnabled = exception_enabled;
Open( db );
}
/*---------------------------------------------------------------------------
@mfunc The destructor closes the cursor (if opened).
---------------------------------------------------------------------------*/
COciCursor::~COciCursor()
{
Close();
if ( m_pStmText != NULL )
{
delete[] m_pStmText;
m_pStmText = NULL;
}
}
/*---------------------------------------------------------------------------
@mfunc Raise database exceptions
@parm Condition to raise the exception
@rdesc bCondition is returned.
---------------------------------------------------------------------------*/
BOOL COciCursor::RaiseDbException( BOOL bCondition )
{
if( ( bCondition ) && ( m_ExceptionEnabled ) )
throw COciException( m_pDb->m_Lda, m_pStmText );
return bCondition;
}
/*---------------------------------------------------------------------------
@mfunc Raise cursor exceptions
@parm Condition to raise the exception
@rdesc bCondition is returned.
---------------------------------------------------------------------------*/
BOOL COciCursor::RaiseCursorException( BOOL bCondition )
{
if( ( bCondition ) && ( m_ExceptionEnabled ) )
throw COciException( m_Cda, m_pStmText );
return bCondition;
}
/*---------------------------------------------------------------------------
@mfunc Open cursor via COciDatabase.
@parm Database object
@rdesc Returns TRUE on success, FALSE on failure.
@devnote This funtion calls the OCI function oopen()
to open the cursor. <nl>
oopen(Cda_Def *cursor, Lda_Def *lda,
text *dbn, sword dbnl, sword arsize,
text *uid, sword uidl);
---------------------------------------------------------------------------*/
BOOL COciCursor::Open( COciDatabase& db )
{
if( !db.IsConnected() )
return FALSE;
m_pDb = &db;
if ( m_ReturnCode != oci_blocked) memset( &m_Cda, 0, sizeof( m_Cda ) );
m_IsConnected = !oopen( &m_Cda, &db.m_Lda, 0, -1, -1, 0, -1);
RaiseDbException( !m_IsConnected );
return m_IsConnected;
}
/*---------------------------------------------------------------------------
@mfunc Close cursor.
@rdesc Returns TRUE on success, FALSE on failure.
@devnote This funtion calls the OCI function oclose()
to disconnect a cursor from the data areas in the Oracle Server
with which it is associated. <nl>
oclose(Cda_Def *cursor);
---------------------------------------------------------------------------*/
BOOL COciCursor::Close( void )
{
if ( !m_IsConnected ) return FALSE;
if( m_pDb )
{
if( !m_pDb->IsConnected() )
{
m_IsConnected = FALSE;
m_pDb = NULL;
return FALSE;
}
}
int result = oclose( &m_Cda );
m_IsConnected = FALSE;
m_pDb = NULL;
RaiseCursorException( result );
return !result;
}
/*---------------------------------------------------------------------------
@mfunc Cancel a query after the desired number of rows have been fetched.
@rdesc Returns TRUE on success, FALSE on failure.
@devnote This funtion calls the OCI function: <nl>
ocan(Cda_Def *cursor);
---------------------------------------------------------------------------*/
BOOL COciCursor::Cancel( void )
{
if ( !m_IsConnected ) return FALSE;
int result = ocan( &m_Cda );
RaiseCursorException( result );
return !result;
}
/*---------------------------------------------------------------------------
@mfunc Set rollback options for non-fatal Oracle errors.
@rdesc Returns TRUE on success, FALSE on failure.
@parm The action to be taken when a non-fatal Oracle error occurs.
If this option is set to zero, all errors, even non-fatal errors,
cause the current transaction to be rolled back.
If this option is set to 2, only the failing row will be rolled
back during a non-fatal row-level error.
This is the default setting. <nl>
NOTE: rbopt parameter is not supported in Oracle Server Version 6
or later.
@parm Specifies whether to wait for resources or return with an error
if they are currently not available. If this option is set to zero,
the program waits indefinitely if resources are not available.
This is the default action. If this option is set to 4, the program
will receive an error return code whenever a resource is requested
but is unavailable. Use of waitopt set to 4 can cause many error
return codes while waiting for internal resources that are locked
for short durations.
The only resource errors received are for resources requested
by the calling process.
@devnote This funtion calls the OCI function oopt()
to set rollback options for non-fatal Oracle errors
involving multi-row INSERT and UPDATE SQL statements.
It also sets wait options in cases where requested resources
are not available; for example, whether to wait for locks. <nl>
oopt(Cda_Def *cursor, sword rbopt, sword waitopt);
---------------------------------------------------------------------------*/
BOOL COciCursor::Option( int rbopt, int waitopt )
{
if ( !m_IsConnected ) return FALSE;
int result = oopt( &m_Cda, rbopt, waitopt );
RaiseCursorException( result );
return !result;
}
/*---------------------------------------------------------------------------
@mfunc Fetch a portion of a LONG or LONG RAW column.
@rdesc Returns TRUE on success, FALSE on failure.
@parm Column number: 1,2,...
@parm Pointer to buffer
@parm Buffer size
@parm Buffer data type, see ext* "enum"
@parm Retu
没有合适的资源?快使用搜索试试~ 我知道了~
Oracle+OCI+API封装类
共37个文件
h:7个
cpp:6个
dsw:4个
3星 · 超过75%的资源 需积分: 9 41 下载量 166 浏览量
2010-11-11
20:57:01
上传
评论
收藏 259KB RAR 举报
温馨提示
ORACLE调用接口(Oracle Call Interface简称OCI)提供了一组可对ORACLE数据库进行存取的接口子例程(函数),通过在第三代程序设计语言(如C语言)中进行调用可达到存取ORACLE数据库的目的。
资源推荐
资源详情
资源评论
收起资源包目录
Oracle+OCI+API封装类.rar (37个子文件)
Oracle OCI API封装类
Include
OciClasses.h 534B
OciExtension.h 1KB
OciException.h 3KB
OciVariable.h 30KB
OciDatabase.h 7KB
OciCursor.h 13KB
OciClassDef.h 632B
www.pudn.com.txt 218B
OciSample
Main.cpp 3KB
OciSampleVC6.dsp 3KB
OciSampleVC6.dsw 544B
OciSampleVC5.dsw 541B
OciSampleVC5.dsp 3KB
OciClassesVC6.dsp 5KB
Doc
OCICLASSES.HPJ 107B
OCICLASSES.RTF 187KB
OCICLASSES.HLP 169KB
OCICLASSES.GID 20KB
UsedOciCalls.doc 25KB
MakeDoc.bat 127B
MakeHlp.bat 156B
CppDocHtml.fmt 41KB
MakeHTML.bat 131B
CppDocHlp.fmt 57KB
CPPDOC.D 1KB
OCICLASSES.DOC 171KB
OciClassesDiagram.doc 25KB
OciClasses.HTM 94KB
Src
OciExample.cpp 3KB
OciCursor.cpp 36KB
OciVariable.cpp 8KB
OciDatabase.cpp 11KB
OciException.cpp 4KB
424440Oracle OCI APIװ.zip 136KB
OciClassesVC6.dsw 546B
OciClassesVC5.dsp 5KB
OciClassesVC5.dsw 543B
共 37 条
- 1
资源评论
- Seymour-Birkhoff2013-08-25谢谢分享,对我一个初学者来说不错。
- flyingpeach2013-04-22对我来说没什么用
- chenmodexiaocao2013-09-03有点失望,和我想要的封装类有点距离
damon-pku
- 粉丝: 39
- 资源: 54
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 信呼OA系统2.1.7版源码
- 3122080306 邹子轩 实验报告二.docx
- 基于STM32 NUCLEO板设计彩色LED照明灯(纯cubeMX开发)(大赛作品,文档完整,可直接运行)
- 发那科工业机器人保养大全
- Sphere.h
- REMD固有时间尺度分解信号分量可视化(Matlab完整源码和数据)
- 嵌入式系统双单片机STC89C52+STC15W104多功能学习板电路图可扩展 适用于单片机初学者和教学
- 基于STM32蓝牙控制小车系统设计(硬件+源代码+论文)大赛作品
- XILINXFPGA源码基于Spartan3火龙刀系列FPGA开发板VGA测试例程
- Java聊天室的设计与实现【尚学堂·百战程序员】
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功