本文整理汇总了C++中OCIErrorGet函数的典型用法代码示例。如果您正苦于以下问题:C++ OCIErrorGet函数的具体用法?C++ OCIErrorGet怎么用?C++ OCIErrorGet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OCIErrorGet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ora_error
// Заполняет текст последней ошибки в db->error
int ora_error(database *db)
{
t_ora *o = db->h;
int len, i , ecode;
unsigned char *err;
debugf("ORA_ERROR on database... try extract text");
//return 0;
//printf("ORA ERROR!!"); getch();
if (!o) sprintf(db->error,"vora - no oracle connection");
else OCIErrorGet((dvoid *)o->errhp, (ub4) 1, (text *) NULL, &db->err_code,
db->error, (ub4) sizeof(db->error), OCI_HTYPE_ERROR );
//printf("ORA ERROR CODE=%d!!",db->err_code); getch();
if (db->err_code == 3113 || db->err_code == 12560 || db->err_code==12571 || db->err_code==3114) { // Clear connection flags
db->connected = 0;
}
err = db->error; len = strlen(err); err+=len;
//printf("Ora error length=%d\n",len);
for ( i=2; i<5 ; i++) { // Не работает - ничего кроме первого не вытаскивается !!!
int l;
OCIErrorGet((dvoid *)o->errhp, (ub4) i, (text *) NULL, &db->err_code,
err, (ub4) (sizeof(db->error) - len-1), OCI_HTYPE_ERROR );
l = strlen(err);
//printf("Ora error length=%d\n",l);
len+= l; err+=l;
}
*err=0; // Terminate it !!!
//printf("ORA ERROR TEXT=%s!!",db->error); getch();
return 0;
}
示例2: statement_fetch_metadata
static void statement_fetch_metadata(lua_State *L, statement_t *statement) {
bindparams_t *bind;
int i;
char errbuf[100];
int errcode;
int rc;
if (statement->metadata)
return;
statement->bind = (bindparams_t *)malloc(sizeof(bindparams_t) * statement->num_columns);
memset(statement->bind, 0, sizeof(bindparams_t) * statement->num_columns);
bind = statement->bind;
for (i = 0; i < statement->num_columns; i++) {
rc = OCIParamGet(statement->stmt, OCI_HTYPE_STMT, statement->conn->err, (dvoid **)&bind[i].param, i+1);
if (rc) {
OCIErrorGet((dvoid *)statement->conn->err, (ub4) 1, (text *) NULL, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
luaL_error(L, "param get %s", errbuf);
}
rc = OCIAttrGet(bind[i].param, OCI_DTYPE_PARAM, (dvoid *)&(bind[i].name), (ub4 *)&(bind[i].name_len), OCI_ATTR_NAME, statement->conn->err);
if (rc) {
OCIErrorGet((dvoid *)statement->conn->err, (ub4) 1, (text *) NULL, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
luaL_error(L, "name get %s", errbuf);
}
rc = OCIAttrGet(bind[i].param, OCI_DTYPE_PARAM, (dvoid *)&(bind[i].data_type), (ub4 *)0, OCI_ATTR_DATA_TYPE, statement->conn->err);
if (rc) {
OCIErrorGet((dvoid *)statement->conn->err, (ub4) 1, (text *) NULL, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
luaL_error(L, "datatype get %s", errbuf);
}
rc = OCIAttrGet(bind[i].param, OCI_DTYPE_PARAM, (dvoid *)&(bind[i].max_len), 0, OCI_ATTR_DATA_SIZE, statement->conn->err);
if (rc) {
OCIErrorGet((dvoid *)statement->conn->err, (ub4) 1, (text *) NULL, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
luaL_error(L, "datasize get %s", errbuf);
}
bind[i].data = calloc(bind[i].max_len+1, sizeof(char));
rc = OCIDefineByPos(statement->stmt, &bind[i].define, statement->conn->err, (ub4)i+1, bind[i].data, bind[i].max_len, SQLT_STR, (dvoid *)&(bind[i].null), (ub2 *)0, (ub2 *)0, (ub4)OCI_DEFAULT);
if (rc) {
OCIErrorGet((dvoid *)statement->conn->err, (ub4) 1, (text *) NULL, &errcode, errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
luaL_error(L, "define by pos %s", errbuf);
}
}
statement->metadata = 1;
}
示例3: while
oraub8 SqlLob::length()
{
if(!is_not_null())
return 0;
bool done = false;
oraub8 len;
while(!done)
{
sword res = OCICALL(OCILobGetLength2(_conn._svc_ctx, _conn._env._errh, _loc, &len));
if( res != OCI_SUCCESS )
{
sb4 errorcode;
sword res2 = OCICALL(OCIErrorGet(_conn._env._errh, 1, NULL, &errorcode, NULL, 0, OCI_HTYPE_ERROR));
assert(res2 == OCI_SUCCESS);
if(errorcode == 3127) // ORA-03127: no new operations allowed until the active operation ends
{
std::cerr << "ORA-03127: no new operations allowed until the active operation ends" << std::endl;
MSLEEP(100);
}
else
{
oci_check_error(__TROTL_HERE__, _conn._env._errh, res);
}
}
else
{
done = true;
}
}
return len;
};
示例4: ocierror
/*---------------------------------------------------------------------
* ocierror - Print error status and exit program
*---------------------------------------------------------------------*/
static void ocierror(oci_t * ocip, char * msg, boolean stop_on_error)
{
sb4 errcode=0;
text bufp[4096];
time_t tm;
time(&tm);
if (ocip->errp)
{
OCIErrorGet((dvoid *) ocip->errp, (ub4) 1, (text *) NULL, &errcode,
bufp, (ub4) 4096, (ub4) OCI_HTYPE_ERROR);
printf("%s\n%s", msg, bufp);
}
else
puts(msg);
printf ("\n=== Current time = %s", ctime(&tm));
printf ("\n");
if (stop_on_error)
{
printf("\n ocierror>> stop_on_error set, exiting...");
if (ocip->attached)
detach_session(ocip, TRUE);
exit(1);
}
}
示例5: yada_oracle_rollback
static int yada_oracle_rollback(yada_t *_yada, int flags)
{
char errbuf[1024];
sb4 errcode;
/* check database connection */
if(!_yada->_mod->env)
{
_yada_set_err(_yada, 0, "database unavailable");
return(-1);
}
if(OCITransRollback(_yada->_mod->ctx, _yada->_mod->err, OCI_DEFAULT)
!= OCI_SUCCESS)
{
OCIErrorGet(_yada->_mod->err, 1, NULL, &errcode, errbuf, sizeof(errbuf),
OCI_HTYPE_ERROR);
_yada_set_err(_yada, errcode, errbuf);
_yada->disconnect(_yada);
return(-1);
}
if(_yada->_mod->flags & ORAF_INTRX)
_yada->_mod->flags ^= ORAF_INTRX;
return(0);
}
示例6: checkerr
/* Handle oci error */
void checkerr(OCIError *errhp, sword status)
{
text errbuf[512];
sb4 errcode = 0;
switch (status)
{
case OCI_SUCCESS:
break;
case OCI_SUCCESS_WITH_INFO:
printf("Error - OCI_SUCCESS_WITH_INFO\n");
break;
case OCI_NEED_DATA:
printf("Error - OCI_NEED_DATA\n");
break;
case OCI_NO_DATA:
printf("Error - OCI_NODATA\n");
break;
case OCI_ERROR:
OCIErrorGet((dvoid *)errhp, (ub4) 1, (text *) NULL, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
printf("Error - %.*s\n", 512, errbuf);
break;
case OCI_INVALID_HANDLE:
printf("Error - OCI_INVALID_HANDLE\n");
break;
case OCI_STILL_EXECUTING:
printf("Error - OCI_STILL_EXECUTE\n");
break;
case OCI_CONTINUE:
printf("Error - OCI_CONTINUE\n");
break;
default:
break;
}
}
示例7: OCIErrorGet
char *ltDbError(ltDbConn *pConn){
ub4 errcode;
static char msgBuf[512];
OCIErrorGet(pConn->pErr, (ub4) 1, (text *) NULL, &errcode,
msgBuf, (ub4) sizeof(msgBuf), OCI_HTYPE_ERROR);
return msgBuf;
}
示例8: ltDbErrorCode
/*错误处理*/
unsigned int ltDbErrorCode(ltDbConn *pConn){
ub4 errcode;
text msgBuf[512];
OCIErrorGet(pConn->pErr, (ub4) 1, (text *) NULL, &errcode,
msgBuf, (ub4) sizeof(msgBuf), OCI_HTYPE_ERROR);
return errcode;
}
示例9: raise_oracle_error
static void
raise_oracle_error(plruby_context_t *ctx, int is_err, sword status, const char *file, long line)
{
text errmsg[OCI_ERROR_MAXMSG_SIZE];
sb4 errcode;
switch (status) {
case OCI_ERROR:
case OCI_SUCCESS_WITH_INFO:
case OCI_NO_DATA:
OCIErrorGet(is_err ? ctx->errhp : ctx->envhp, 1, NULL, &errcode, errmsg, sizeof(errmsg),
is_err ? OCI_HTYPE_ERROR : OCI_HTYPE_ENV);
rb_raise(rb_eRuntimeError, "OCI Error(%s:%ld): %s", file, line, errmsg);
break;
case OCI_INVALID_HANDLE:
rb_raise(rb_eRuntimeError, "OCI Error(%s:%ld): Invalid Handle", file, line);
break;
case OCI_NEED_DATA:
rb_raise(rb_eRuntimeError, "OCI Error(%s:%ld): Need Data", file, line);
break;
case OCI_STILL_EXECUTING:
rb_raise(rb_eRuntimeError, "OCI Error(%s:%ld): Still Executing", file, line);
break;
case OCI_CONTINUE:
rb_raise(rb_eRuntimeError, "OCI Error(%s:%ld): Continue", file, line);
break;
default:
rb_raise(rb_eRuntimeError, "OCI error(%s:%ld): Unknown code %d", file, line, status);
}
}
示例10: OCI_ExceptionGetError
void OCI_ExceptionOCI
(
OCIError *p_err,
OCI_Connection *con,
OCI_Statement *stmt,
boolean warning
)
{
OCI_Error *err = OCI_ExceptionGetError();
if (err)
{
int dbsize = (int) (osizeof(err->str) - (size_t) 1);
dbtext *dbstr = OCI_StringGetOracleString(err->str, &dbsize);
err->type = (warning ? OCI_ERR_WARNING : OCI_ERR_ORACLE);
err->con = con;
err->stmt = stmt;
/* get oracle description */
OCIErrorGet((dvoid *) p_err, (ub4) 1, (OraText *) NULL, &err->sqlcode,
(OraText *) dbstr, (ub4) dbsize, (ub4) OCI_HTYPE_ERROR);
OCI_StringCopyOracleStringToNativeString(dbstr, err->str, dbcharcount(dbsize));
OCI_StringReleaseOracleString(dbstr);
}
OCI_ExceptionRaise(err);
}
示例11: switch
const char *OracleConnection_getLastError(T C) {
sb4 errcode;
switch (C->lastError)
{
case OCI_SUCCESS:
return "";
case OCI_SUCCESS_WITH_INFO:
return "Error - OCI_SUCCESS_WITH_INFO";
break;
case OCI_NEED_DATA:
return "Error - OCI_NEED_DATA";
break;
case OCI_NO_DATA:
return "Error - OCI_NODATA";
break;
case OCI_ERROR:
(void) OCIErrorGet(C->err, 1, NULL, &errcode, C->erb, (ub4)ERB_SIZE, OCI_HTYPE_ERROR);
return C->erb;
break;
case OCI_INVALID_HANDLE:
return "Error - OCI_INVALID_HANDLE";
break;
case OCI_STILL_EXECUTING:
return "Error - OCI_STILL_EXECUTE";
break;
case OCI_CONTINUE:
return "Error - OCI_CONTINUE";
break;
default:
break;
}
return C->erb;
}
示例12: qxiqtce
/*---------------------------------------------------------------------------
PRIVATE FUNCTIONS
---------------------------------------------------------------------------*/
static int qxiqtce(
OCIExtProcContext *ctx,
OCIError *errhp,
sword status)
{
text errbuf[512];
sb4 errcode = 0;
int errnum = 29400; /* choose some oracle error number */
int rc = 0;
switch (status)
{
case OCI_SUCCESS:
rc = 0;
break;
case OCI_ERROR:
(void) OCIErrorGet((dvoid *)errhp, (ub4)1, (text *)NULL, &errcode,
errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
OCIExtProcRaiseExcpWithMsg(ctx, errnum, errbuf, strlen((char *)errbuf));
rc = 1;
break;
default:
(void) sprintf((char *)errbuf, "Warning - some error\n");
OCIExtProcRaiseExcpWithMsg(ctx, errnum, errbuf, strlen((char *)errbuf));
rc = 1;
break;
}
return (rc);
}
示例13: logOraError
/*
call SQLError to get error information and log it
*/
int
logOraError( int level, OCIError *errhp, sword status ) {
sb4 errcode;
int errorVal = -1;
if ( status == OCI_SUCCESS ) {
return 0;
}
switch ( status ) {
case OCI_SUCCESS_WITH_INFO:
rodsLog( level, "OCI_SUCCESS_WITH_INFO" );
OCIErrorGet( ( dvoid * ) errhp, ( ub4 ) 1, ( text * ) NULL, &errcode,
oraErrorMsg, ( ub4 ) sizeof( oraErrorMsg ),
( ub4 ) OCI_HTYPE_ERROR );
rodsLog( level, "Error - %s\n", oraErrorMsg );
errorVal = 0;
break;
case OCI_NEED_DATA:
rodsLog( level, "OCI_NEED_DATA" );
break;
case OCI_NO_DATA:
rodsLog( level, "OCI_NO_DATA" );
errorVal = 0;
break;
case OCI_ERROR:
OCIErrorGet( ( dvoid * ) errhp, ( ub4 ) 1, ( text * ) NULL, &errcode,
oraErrorMsg, ( ub4 ) sizeof( oraErrorMsg ),
( ub4 ) OCI_HTYPE_ERROR );
rodsLog( level, "OCI_Error: %s", oraErrorMsg );
if ( strstr( ( char * )oraErrorMsg, "unique constraint" ) != 0 ) {
errorVal = CATALOG_ALREADY_HAS_ITEM_BY_THAT_NAME;
}
break;
case OCI_INVALID_HANDLE:
rodsLog( level, "OCI_INVALID_HANDLE\n" );
break;
case OCI_STILL_EXECUTING:
rodsLog( level, "OCI_STILL_EXECUTING\n" );
break;
case OCI_CONTINUE:
rodsLog( level, "OCI_CONTINUE\n" );
break;
default:
rodsLog( level, "Unknown OCI status - %d", status );
break;
}
return errorVal;
}
示例14: CheckErr
void CheckErr(OCIError *errhp, int ret) {
char errbuf[512];
if (ret == OCI_ERROR) {
OCIErrorGet((dvoid*)errhp, (ub4)1, (text*)NULL, (sb4*)&ret, (text*)errbuf,
(ub4)sizeof(errbuf), (ub4)OCI_HTYPE_ERROR);
errbuf[strlen(errbuf)-1] = 0;
Log("ERROR: %s", errbuf);
}
}
示例15: oci_errors
/** Generic function for handling errors from OCI.
It will be called only inside CHECKERR and CHECKENV macros.
Arguments: handle The error or environment handle to check.
htype: OCI_HTYPE_* constant, usually OCI_HTYPE_ERROR or
OCI_HTYPE_ENV
status: status code to check, usually the return value of an OCI
function.
Returns OCI_SUCCESS on success, OCI_ERROR otherwise.
*/
static int oci_errors(void* handle, ub4 htype, sword status)
{
sb4 errcode;
unsigned char buf[MAX_BUFSIZE];
switch (status) {
case OCI_SUCCESS:
return OCI_SUCCESS;
break;
case OCI_SUCCESS_WITH_INFO:
OCIErrorGet(handle, 1, NULL, &errcode, buf, sizeof buf, htype);
errmsg.LogError(0, NO_ERRCODE, "OCI SUCCESS - With info: %s",
buf);
return OCI_SUCCESS_WITH_INFO;
case OCI_NEED_DATA:
errmsg.LogError(0, NO_ERRCODE, "OCI NEEDS MORE DATA\n");
break;
case OCI_ERROR:
dbgprintf ("OCI GENERAL ERROR\n");
if (handle) {
OCIErrorGet(handle, 1, NULL, &errcode, buf,
sizeof buf, htype);
errmsg.LogError(0, NO_ERRCODE, "Error message: %s", buf);
} else
errmsg.LogError(0, NO_ERRCODE, "NULL handle\n"
"Unable to extract further "
"information");
break;
case OCI_INVALID_HANDLE:
errmsg.LogError(0, NO_ERRCODE, "OCI INVALID HANDLE\n");
/* In this case we may have to trigger a call to
* tryResume(). */
return RS_RET_SUSPENDED;
break;
case OCI_STILL_EXECUTING:
errmsg.LogError(0, NO_ERRCODE, "Still executing...\n");
break;
case OCI_CONTINUE:
errmsg.LogError(0, NO_ERRCODE, "OCI CONTINUE\n");
break;
}
return OCI_ERROR;
}