当前位置: 首页>>代码示例>>C++>>正文


C++ OCIHandleAlloc函数代码示例

本文整理汇总了C++中OCIHandleAlloc函数的典型用法代码示例。如果您正苦于以下问题:C++ OCIHandleAlloc函数的具体用法?C++ OCIHandleAlloc怎么用?C++ OCIHandleAlloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了OCIHandleAlloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PrepareDbTime

void PrepareDbTime()
{
   OCIBind *bndv1 = 0;
   OCIBind *bndv2 = 0;

   static text *stmt_cputime = (text *) "begin :cpu_time_value := dbms_utility.get_cpu_time(); end;" ;
   static text *stmt_elptime = (text *) "begin :elp_time_value := dbms_utility.get_time(); end;" ;

   /* Allocate cpu time handle */ 
   CheckErr(errhp, OCIHandleAlloc(envhp, (dvoid **) &stmt_cputimehp,
                                     OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0));

   /* Allocate elapsed time handle */ 
   CheckErr(errhp, OCIHandleAlloc(envhp, (dvoid **) &stmt_elptimehp,
                                     OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0));

   /* Prepare cpu time statement */
   CheckErr(errhp, OCIStmtPrepare(stmt_cputimehp, errhp, (CONST text *) stmt_cputime,
                                     strlen((char *) stmt_cputime), OCI_NTV_SYNTAX, OCI_DEFAULT));

   /* Prepare elapsed time statement */
   CheckErr(errhp, OCIStmtPrepare(stmt_elptimehp, errhp, (CONST text *) stmt_elptime,
                                     strlen((char *) stmt_elptime), OCI_NTV_SYNTAX, OCI_DEFAULT));

   /* Bind cpu_time_value variable */
   CheckErr(errhp, OCIBindByName(stmt_cputimehp, (OCIBind **) &bndv1, errhp,
                         (text *)":cpu_time_value", (sb4) 15, &cpu_time_value, (sb4) sizeof(ub4), SQLT_INT,
                         (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT));

   /* Bind elp_time_value variable */
   CheckErr(errhp, OCIBindByName(stmt_elptimehp, (OCIBind **) &bndv2, errhp,
                         (text *)":elp_time_value", (sb4) 15, &elp_time_value, (sb4) sizeof(ub4), SQLT_INT,
                         (dvoid *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT));
}
开发者ID:RicardoVivas,项目名称:oracle-scripts,代码行数:34,代码来源:LobUtilFunc.c

示例2: AllocateHandles

sword AllocateHandles(ub1 mymem)
{

    if (OCIEnvCreate(&envhp,
                         (ub4) OCI_DEFAULT,
                         (dvoid *)0,
                         (dvoid * (*)(dvoid *, size_t)) 0,
                         (dvoid * (*)(dvoid *, dvoid *, size_t))0,
                         (void (*)(dvoid *, dvoid *)) 0,
                         0,
                         (dvoid **) 0) != OCI_SUCCESS) {
            return OCI_ERROR;
    }
 
    /* allocate an error handle withtin the environment */
    if (OCIHandleAlloc((dvoid *) envhp, (dvoid **) &errhp,
                       (ub4) OCI_HTYPE_ERROR, (size_t) 0, (dvoid **) 0)) {
        printf("OCIHandleAlloc failed for errhp\n");
        return OCI_ERROR;
    }
    
    /* allocate a service context handle within the environment */
    if (OCIHandleAlloc((dvoid *) envhp, (dvoid **) &svchp ,
                       (ub4) OCI_HTYPE_SVCCTX, (size_t) 0, (dvoid **) 0)) {
        printf("OCIHandleAlloc failed for context\n");
        return OCI_ERROR;
    }
    
    return OCI_SUCCESS;
}
开发者ID:RicardoVivas,项目名称:oracle-scripts,代码行数:30,代码来源:LobUtilFunc.c

示例3: _doConnect

static int _doConnect(T C, URL_T url, char**  error) {
#undef ERROR
#define ERROR(e) do {*error = Str_dup(e); return false;} while (0)
#define ORAERROR(e) do{ *error = Str_dup(OracleConnection_getLastError(e)); return false;} while(0)
        const char *database, *username, *password;
        const char *host = URL_getHost(url);
        int port = URL_getPort(url);
        if (! (username = URL_getUser(url)))
                if (! (username = URL_getParameter(url, "user")))
                        ERROR("no username specified in URL");
        if (! (password = URL_getPassword(url)))
                if (! (password = URL_getParameter(url, "password")))
                        ERROR("no password specified in URL");
        if (! (database = URL_getPath(url)))
                ERROR("no database specified in URL");
        ++database;
        /* Create a thread-safe OCI environment with N' substitution turned on. */
        if (OCIEnvCreate(&C->env, OCI_THREADED | OCI_OBJECT | OCI_NCHAR_LITERAL_REPLACE_ON, 0, 0, 0, 0, 0, 0))
                ERROR("Create a OCI environment failed");
        /* allocate an error handle */
        if (OCI_SUCCESS != OCIHandleAlloc(C->env, (dvoid**)&C->err, OCI_HTYPE_ERROR, 0, 0))
                ERROR("Allocating error handler failed");
        /* server contexts */
        if (OCI_SUCCESS != OCIHandleAlloc(C->env, (dvoid**)&C->srv, OCI_HTYPE_SERVER, 0, 0))
                ERROR("Allocating server context failed");
        /* allocate a service handle */
        if (OCI_SUCCESS != OCIHandleAlloc(C->env, (dvoid**)&C->svc, OCI_HTYPE_SVCCTX, 0, 0))
                ERROR("Allocating service handle failed");
        StringBuffer_clear(C->sb);
        /* Oracle connect string is on the form: //host[:port]/service name */
        if (host) {
                StringBuffer_append(C->sb, "//%s", host);
                if (port > 0)
                        StringBuffer_append(C->sb, ":%d", port);
                StringBuffer_append(C->sb, "/%s", database);
        } else /* Or just service name */
                StringBuffer_append(C->sb, "%s", database);
        /* Create a server context */
        C->lastError = OCIServerAttach(C->srv, C->err, StringBuffer_toString(C->sb), StringBuffer_length(C->sb), 0);
        if (C->lastError != OCI_SUCCESS && C->lastError != OCI_SUCCESS_WITH_INFO)
                ORAERROR(C);
        /* Set attribute server context in the service context */
        C->lastError = OCIAttrSet(C->svc, OCI_HTYPE_SVCCTX, C->srv, 0, OCI_ATTR_SERVER, C->err);
        if (C->lastError != OCI_SUCCESS && C->lastError != OCI_SUCCESS_WITH_INFO)
                ORAERROR(C);
        C->lastError = OCIHandleAlloc(C->env, (void**)&C->usr, OCI_HTYPE_SESSION, 0, NULL);
        if (C->lastError != OCI_SUCCESS && C->lastError != OCI_SUCCESS_WITH_INFO)
                ORAERROR(C);
        C->lastError = OCIAttrSet(C->usr, OCI_HTYPE_SESSION, (dvoid *)username, (int)strlen(username), OCI_ATTR_USERNAME, C->err);
        if (C->lastError != OCI_SUCCESS && C->lastError != OCI_SUCCESS_WITH_INFO)
                ORAERROR(C);
        C->lastError = OCIAttrSet(C->usr, OCI_HTYPE_SESSION, (dvoid *)password, (int)strlen(password), OCI_ATTR_PASSWORD, C->err);
        if (C->lastError != OCI_SUCCESS && C->lastError != OCI_SUCCESS_WITH_INFO)
                ORAERROR(C);
        C->lastError = OCISessionBegin(C->svc, C->err, C->usr, OCI_CRED_RDBMS, OCI_DEFAULT);
        if (C->lastError != OCI_SUCCESS && C->lastError != OCI_SUCCESS_WITH_INFO)
                ORAERROR(C);
        OCIAttrSet(C->svc, OCI_HTYPE_SVCCTX, C->usr, 0, OCI_ATTR_SESSION, C->err);
        return true;
}
开发者ID:chengjunjian,项目名称:libzdb_msvc,代码行数:60,代码来源:OracleConnection.c

示例4: oci8_allocate_handles

/*
 * call-seq:
 *   allocate_handles()
 *
 * <b>internal use only</b>
 *
 * Allocates a service context handle, a session handle and a
 * server handle to use explicit attach and begin-session calls.
 */
static VALUE oci8_allocate_handles(VALUE self)
{
    oci8_svcctx_t *svcctx = DATA_PTR(self);
    sword rv;

    if (svcctx->logoff_strategy != NULL) {
        rb_raise(rb_eRuntimeError, "Could not reuse the session.");
    }
    svcctx->logoff_strategy = &complex_logoff;
    svcctx->state = 0;

    /* allocate a service context handle */
    rv = OCIHandleAlloc(oci8_envhp, &svcctx->base.hp.ptr, OCI_HTYPE_SVCCTX, 0, 0);
    if (rv != OCI_SUCCESS)
        oci8_env_raise(oci8_envhp, rv);
    svcctx->base.type = OCI_HTYPE_SVCCTX;

    /* alocalte a session handle */
    rv = OCIHandleAlloc(oci8_envhp, (void*)&svcctx->usrhp, OCI_HTYPE_SESSION, 0, 0);
    if (rv != OCI_SUCCESS)
        oci8_env_raise(oci8_envhp, rv);
    copy_session_handle(svcctx);

    /* alocalte a server handle */
    rv = OCIHandleAlloc(oci8_envhp, (void*)&svcctx->srvhp, OCI_HTYPE_SERVER, 0, 0);
    if (rv != OCI_SUCCESS)
        oci8_env_raise(oci8_envhp, rv);
    copy_server_handle(svcctx);
    return self;
}
开发者ID:jcasts,项目名称:ruby-oci8,代码行数:39,代码来源:oci8.c

示例5: main

int main(int argc, char *argv[])
{
  OCIError *errhp = NULL;

  printf("stage4: Demonstrating OCI statement caching \n");

  /* parse command line options */
  parse_options(argc, argv);
  
  checkenv(envhp, OCIEnvCreate(&envhp,                /* returned env handle */
                               OCI_THREADED,         /* initialization modes */
                               NULL, NULL, NULL, NULL, /* callbacks, context */
                               (size_t) 0,    /* extra memory size: optional */
                               (void **) NULL));    /* returned extra memory */

  /* allocate error handle
   * note: for OCIHandleAlloc(), we always check error on environment handle
   */
  checkenv(envhp, OCIHandleAlloc(envhp,                /* environment handle */
                                 (void **) &errhp,    /* returned err handle */
                                 OCI_HTYPE_ERROR,/*type of handle to allocate*/
                                 (size_t) 0,  /* extra memory size: optional */
                                 (void **) NULL));  /* returned extra memory */

  create_session_pool(envhp, errhp, &poolName, &poolNameLen);

  /* allocate auth handle
   * note: for OCIHandleAlloc(), we check error on environment handle
   */
  checkenv(envhp, OCIHandleAlloc(envhp,
                          (void **) &authp, OCI_HTYPE_AUTHINFO,
                          (size_t) 0, (void **) NULL));

  /* setup username and password */
  checkerr(errhp, OCIAttrSet(authp, OCI_HTYPE_AUTHINFO,
                             (void *) username, strlen((char *)username),
                             OCI_ATTR_USERNAME, errhp));

  checkerr(errhp, OCIAttrSet(authp, OCI_HTYPE_AUTHINFO,
                            apppassword, strlen((char *) apppassword),
                            OCI_ATTR_PASSWORD, errhp));

  spawn_threads(envhp, errhp, &thread_function);
  
  /* Destroy the session pool */
  OCISessionPoolDestroy(spoolhp, errhp, OCI_DEFAULT);

  /* clean up */
  if (authp)
    OCIHandleFree(authp, OCI_HTYPE_AUTHINFO);
  if (spoolhp)
    OCIHandleFree(spoolhp, OCI_HTYPE_SPOOL); 
  if (errhp)
    OCIHandleFree(errhp, OCI_HTYPE_ERROR);
  if (envhp)
    OCIHandleFree(envhp, OCI_HTYPE_ENV);
  
  return 0;
}
开发者ID:Laukien,项目名称:test,代码行数:59,代码来源:stage4.c

示例6: init

ocisession::ocisession(const char * connect_str, const int connect_str_len,
					   const char * user_name, const int user_name_len,
					   const char * password, const int password_len)
{
	intf_ret r;
	OCIAuthInfo *authp = NULL;

	init();

	r.handle = envhp;

	// allocate error handle
	checkenv(&r, OCIHandleAlloc((OCIEnv*)envhp,	/* environment handle */
                            (void **) &_errhp,	/* returned err handle */
                            OCI_HTYPE_ERROR,	/* typ of handle to allocate */
                            (size_t) 0,			/* optional extra memory size */
                            (void **) NULL));	/* returned extra memeory */

	if(r.fn_ret != SUCCESS) {
   		REMOTE_LOG("failed OCISessionGet %s\n", r.gerrbuf);
        throw r;
	}

	// allocate auth handle
	checkenv(&r, OCIHandleAlloc((OCIEnv*)envhp,
							(void**)&authp, OCI_HTYPE_AUTHINFO,
							(size_t)0, (void **) NULL));

	r.handle = _errhp;

	// usrname and password
	checkerr(&r, OCIAttrSet(authp, OCI_HTYPE_AUTHINFO,
								(void*) user_name, user_name_len,
								OCI_ATTR_USERNAME, (OCIError *)_errhp));
	checkerr(&r, OCIAttrSet(authp, OCI_HTYPE_AUTHINFO,
								(void*) password, password_len,
								OCI_ATTR_PASSWORD, (OCIError *)_errhp));


    /* get the database connection */
    checkerr(&r, OCISessionGet((OCIEnv*)envhp, (OCIError *)_errhp,
                               (OCISvcCtx**)&_svchp,					/* returned database connection */
                               authp,									/* initialized authentication handle */                               
                               (OraText *) connect_str, connect_str_len,/* connect string */
                               NULL, 0, NULL, NULL, NULL,				/* session tagging parameters: optional */
                               OCI_SESSGET_STMTCACHE));					/* modes */
	if(r.fn_ret != SUCCESS) {
		REMOTE_LOG("failed OCISessionGet %s\n", r.gerrbuf);
        throw r;
	}

	(void) OCIHandleFree(authp, OCI_HTYPE_AUTHINFO);

	REMOTE_LOG("got session %p\n", _svchp);

	_sessions.push_back(this);
}
开发者ID:Zabrane,项目名称:erloci,代码行数:57,代码来源:ocisession.cpp

示例7: InitHandles

void InitHandles() {
	if (OCIEnvCreate(&henv, OCI_DEFAULT, NULL, NULL, NULL, NULL, 0, NULL) ||
		OCIHandleAlloc(henv, (dvoid*)&hser, OCI_HTYPE_SERVER, 0, NULL) ||
		OCIHandleAlloc(henv, (dvoid*)&herr, OCI_HTYPE_ERROR, 0, NULL) ||
		OCIHandleAlloc(henv, (dvoid*)&husr, OCI_HTYPE_SESSION, 0, NULL) ||
		OCIHandleAlloc(henv, (dvoid*)&hsvc, OCI_HTYPE_SVCCTX, 0, NULL) ||
		OCIHandleAlloc(henv, (dvoid*)&hsql, OCI_HTYPE_STMT, 0, NULL)) {
		Log("initialize handles failed");
		exit(2);
	}
}
开发者ID:boyfaceone,项目名称:codebase,代码行数:11,代码来源:oracli.c

示例8: sql_init_socket

/*************************************************************************
 *
 *	Function: sql_init_socket
 *
 *	Purpose: Establish connection to the db
 *
 *************************************************************************/
static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) {

	rlm_sql_oracle_sock *oracle_sock;

	if (!sqlsocket->conn) {
		sqlsocket->conn = (rlm_sql_oracle_sock *)rad_malloc(sizeof(rlm_sql_oracle_sock));
		if (!sqlsocket->conn) {
			return -1;
		}
	}
	memset(sqlsocket->conn,0,sizeof(rlm_sql_oracle_sock));

	oracle_sock = sqlsocket->conn;

	if (OCIEnvCreate(&oracle_sock->env, OCI_DEFAULT|OCI_THREADED, (dvoid *)0,
		(dvoid * (*)(dvoid *, size_t)) 0,
		(dvoid * (*)(dvoid *, dvoid *, size_t))0,
		(void (*)(dvoid *, dvoid *)) 0,
		0, (dvoid **)0 )) {
		radlog(L_ERR,"rlm_sql_oracle: Couldn't init Oracle OCI environment (OCIEnvCreate())");
		return -1;
	}

	if (OCIHandleAlloc((dvoid *) oracle_sock->env, (dvoid **) &oracle_sock->errHandle,
		(ub4) OCI_HTYPE_ERROR, (size_t) 0, (dvoid **) 0))
	{
		radlog(L_ERR,"rlm_sql_oracle: Couldn't init Oracle ERROR handle (OCIHandleAlloc())");
		return -1;
	}

	/* Allocate handles for select and update queries */
	if (OCIHandleAlloc((dvoid *)oracle_sock->env, (dvoid **) &oracle_sock->queryHandle,
				(ub4)OCI_HTYPE_STMT, (CONST size_t) 0, (dvoid **) 0))
	{
		radlog(L_ERR,"rlm_sql_oracle: Couldn't init Oracle query handles: %s",
			sql_error(sqlsocket, config));
		return -1;
	}


	if (OCILogon(oracle_sock->env, oracle_sock->errHandle, &oracle_sock->conn,
			config->sql_login, strlen(config->sql_login),
			config->sql_password,  strlen(config->sql_password),
			config->sql_db, strlen(config->sql_db)))
	{
		radlog(L_ERR,"rlm_sql_oracle: Oracle logon failed: '%s'", sql_error(sqlsocket, config));
		sql_close(sqlsocket,config);
		return -1;
	}

	return 0;
}
开发者ID:101,项目名称:freeradius-server,代码行数:59,代码来源:sql_oracle.c

示例9: ConnectToDb

sword ConnectToDb(const char* const uid, const char* const pwd)
{
    sword orc;

    /* allocate Server and Authentication (Session) handles */
    orc = OCIHandleAlloc((dvoid *) envhp, 
                         (dvoid **) &srvhp,
                         (ub4) OCI_HTYPE_SERVER, 
                         (size_t) 0, (dvoid **) 0);

    orc = OCIHandleAlloc((dvoid *) envhp, 
                         (dvoid **) &authp,
                         (ub4) OCI_HTYPE_SESSION, 
                         (size_t) 0, (dvoid **) 0);
    
    /* attach to the server */
    orc = OCIServerAttach(srvhp, errhp, (text *) 0, 0, (ub4) OCI_DEFAULT);
     
    orc = OCIAttrSet((dvoid *) authp, 
                     (ub4) OCI_HTYPE_SESSION,
                     (dvoid *) uid, (ub4) strlen((char *)uid),
                     (ub4) OCI_ATTR_USERNAME, errhp);
    
    orc = OCIAttrSet((dvoid *) authp, 
                     (ub4) OCI_HTYPE_SESSION,
                     (dvoid *) pwd, (ub4) strlen((char *)pwd),
                     (ub4) OCI_ATTR_PASSWORD, errhp);

    /* set the server attribute in the service context */
    orc = OCIAttrSet((dvoid *) svchp, 
                     (ub4) OCI_HTYPE_SVCCTX,
                     (dvoid *) srvhp, 
                     (ub4) 0, (ub4) OCI_ATTR_SERVER, errhp);
     
    /* log on */
    orc = OCISessionBegin(svchp, errhp, authp, 
                          (ub4) OCI_CRED_RDBMS,
                          (ub4) OCI_DEFAULT);
     
    CheckErr(errhp, orc);

    /* set the session attribute in the service context */
    orc = OCIAttrSet((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX, 
                     (dvoid *) authp,
                     (ub4) 0, (ub4) OCI_ATTR_SESSION, errhp);

    return (orc);
} /* ConnectToDb */
开发者ID:RicardoVivas,项目名称:oracle-scripts,代码行数:48,代码来源:LobUtilFunc.c

示例10: dbd_oracle_statement_create

int dbd_oracle_statement_create(lua_State *L, connection_t *conn, const char *sql_query) { 
    int rc;
    statement_t *statement = NULL;
    OCIStmt *stmt;
    char *new_sql;

    /*
     * convert SQL string into a Oracle API compatible SQL statement
     */
    new_sql = replace_placeholders(L, ':', sql_query);

    rc = OCIHandleAlloc((dvoid *)conn->oracle, (dvoid **)&stmt, OCI_HTYPE_STMT, 0, (dvoid **)0);
    rc = OCIStmtPrepare(stmt, conn->err, new_sql, strlen(new_sql), (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT);

    free(new_sql);

    statement = (statement_t *)lua_newuserdata(L, sizeof(statement_t));
    statement->conn = conn;
    statement->stmt = stmt;
    statement->num_columns = 0;
    statement->bind = NULL;
    statement->metadata = 0;

    luaL_getmetatable(L, DBD_ORACLE_STATEMENT);
    lua_setmetatable(L, -2);

    return 1;
} 
开发者ID:clandmeter,项目名称:luadbi,代码行数:28,代码来源:statement.c

示例11: oci8_cpool_initialize

/*
 * call-seq:
 *   OCI8::ConnectionPool.new(conn_min, conn_max, conn_incr, username = nil, password = nil, dbname = nil) -> connection pool
 *   OCI8::ConnectionPool.new(conn_min, conn_max, conn_incr, connect_string) -> connection pool
 *
 * Creates a connection pool.
 *
 * <i>conn_min</i> specifies the minimum number of connections in the
 * connection pool. Valid values are 0 and higher.
 *
 * <i>conn_max</i> specifies the maximum number of connections that
 * can be opened to the database. Once this value is reached, no more
 * connections are opened. Valid values are 1 and higher.
 *
 * <i>conn_incr</i> allows the application to set the next increment
 * for connections to be opened to the database if the current number
 * of connections are less than <i>conn_max</i>. Valid values are 0
 * and higher.
 *
 * <i>username</i> and <i>password</i> are required to establish an
 * implicit primary session. When both are nil, external
 * authentication is used.
 *
 * <i>dbname</i> specifies the database server to connect to.
 *
 * If the number of arguments is four, <i>username</i>,
 * <i>password</i> and <i>dbname</i> are extracted from the fourth
 * argument <i>connect_string</i>. The syntax is "username/password" or
 * "username/[email protected]".
 */
static VALUE oci8_cpool_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE conn_min;
    VALUE conn_max;
    VALUE conn_incr;
    VALUE username;
    VALUE password;
    VALUE dbname;
    oci8_cpool_t *cpool = DATA_PTR(self);
    OraText *pool_name;
    sb4 pool_name_len;
    sword rv;

    /* check arguments */
    rb_scan_args(argc, argv, "42", &conn_min, &conn_max, &conn_incr,
                 &username, &password, &dbname);
    Check_Type(conn_min, T_FIXNUM);
    Check_Type(conn_max, T_FIXNUM);
    Check_Type(conn_incr, T_FIXNUM);
    if (argc == 4) {
        VALUE mode;
        VALUE conn_str = username;

        OCI8SafeStringValue(conn_str);
        oci8_do_parse_connect_string(conn_str, &username, &password, &dbname, &mode);
        if (!NIL_P(mode)) {
            rb_raise(rb_eArgError, "invalid connect string \"%s\": Connection pooling doesn't support sysdba and sysoper privileges.", RSTRING_PTR(conn_str));
        }
    } else {
        if (!NIL_P(username)) {
            OCI8SafeStringValue(username);
        }
        if (!NIL_P(password)) {
            OCI8SafeStringValue(password);
        }
        if (!NIL_P(dbname)) {
            OCI8SafeStringValue(dbname);
        }
    }

    rv = OCIHandleAlloc(oci8_envhp, &cpool->base.hp.ptr, OCI_HTYPE_CPOOL, 0, NULL);
    if (rv != OCI_SUCCESS)
        oci8_env_raise(oci8_envhp, rv);
    cpool->base.type = OCI_HTYPE_CPOOL;

    oci_lc(OCIConnectionPoolCreate(oci8_envhp, oci8_errhp, cpool->base.hp.poolhp,
                                   &pool_name, &pool_name_len,
                                   NIL_P(dbname) ? NULL : RSTRING_ORATEXT(dbname),
                                   NIL_P(dbname) ? 0 : RSTRING_LEN(dbname),
                                   FIX2UINT(conn_min), FIX2UINT(conn_max),
                                   FIX2UINT(conn_incr),
                                   NIL_P(username) ? NULL : RSTRING_ORATEXT(username),
                                   NIL_P(username) ? 0 : RSTRING_LEN(username),
                                   NIL_P(password) ? NULL : RSTRING_ORATEXT(password),
                                   NIL_P(password) ? 0 : RSTRING_LEN(password),
                                   OCI_DEFAULT));
    cpool->pool_name = rb_str_new(TO_CHARPTR(pool_name), pool_name_len);
    rb_str_freeze(cpool->pool_name);
    return Qnil;
}
开发者ID:adanmayer,项目名称:ruby-oci8,代码行数:90,代码来源:connection_pool.c

示例12: ASSERT

        void Statement::Prepare(std::string const& sqlBlock)
        {
            ASSERT(m_conn != NULL && sqlBlock.empty() != true);
            ASSERT(m_stmtHandle == NULL);
            sword result;

            result  = OCIHandleAlloc(m_conn->m_environmentHandle
                        , (void **) &m_stmtHandle,OCI_HTYPE_STMT, 0, NULL);
            if(result == OCI_SUCCESS)
            {
                result  = OCIStmtPrepare(m_stmtHandle, m_conn->m_errorHandle
                            , (text*) sqlBlock.c_str(), sqlBlock.size(), OCI_NTV_SYNTAX, OCI_DEFAULT);
            }
            else
            {
                throw Error (result, m_conn->m_environmentHandle, __FILE__, __LINE__);
            }
            if(result == OCI_SUCCESS)
            {
                ub2 stmtType = 0;
                result = OCIAttrGet (m_stmtHandle, OCI_HTYPE_STMT
                        , &stmtType, NULL, OCI_ATTR_STMT_TYPE, m_conn->m_errorHandle);
                m_type = (StatementType)stmtType;
            }
            if( result == OCI_SUCCESS)
            {
                m_isPrepared = true;
                m_isExecuted = false; 
            }
            else
            {
                throw Error (result, m_conn->m_errorHandle, __FILE__, __LINE__);
            }
        }
开发者ID:vinilin,项目名称:CTI,代码行数:34,代码来源:Statement.cpp

示例13: db_getn

static int db_getn(int type, int keytype)
{
    int        n = 0;
    char       table[20];
    char      *sql =  "select count(*) as n from %s where type=%d";
    OraText    row[4000];
    OCIDefine *dnp = NULL;

    strcpy(table, (type == TYPE_KILL)? "kill_key" : "monitor_key");
    sprintf((char*)row, sql,table, keytype);
    checkerr(OCIHandleAlloc((dvoid *)myenvhp, (dvoid **)&mystmthp,
                            OCI_HTYPE_STMT, (size_t)0, (dvoid **)0), myerrhp);
    checkerr(OCIStmtPrepare(mystmthp, myerrhp, row, (ub4)strlen((char*)row),
                            (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT), myerrhp);
    checkerr(OCIStmtExecute(mysvchp, mystmthp, myerrhp, (ub4)0, (ub4)0,
                            (CONST OCISnapshot *)0, (OCISnapshot *)0,
                            OCI_DEFAULT), myerrhp);
    if ((status = OCIDefineByPos(mystmthp, &dnp, myerrhp, 1, &n, sizeof(n),
                                 SQLT_INT, (dvoid *)0, 0, (ub2 *)0,
                                 OCI_DEFAULT))) {
        checkerr(status, myerrhp);
        return -1;
    }
    if(OCIStmtFetch2(mystmthp, myerrhp, 1, OCI_FETCH_NEXT, 0,
                     OCI_DEFAULT) != OCI_NO_DATA) {
        return n;
    }
    return 0;
}
开发者ID:hongwozai,项目名称:emms,代码行数:29,代码来源:db.c

示例14: o_init

static int o_init (void) /* {{{ */
{
  int status;

  if (oci_env != NULL)
    return (0);

  status = OCIEnvCreate (&oci_env,
      /* mode = */ OCI_THREADED,
      /* context        = */ NULL,
      /* malloc         = */ NULL,
      /* realloc        = */ NULL,
      /* free           = */ NULL,
      /* user_data_size = */ 0,
      /* user_data_ptr  = */ NULL);
  if (status != 0)
  {
    ERROR ("oracle plugin: OCIEnvCreate failed with status %i.", status);
    return (-1);
  }

  status = OCIHandleAlloc (oci_env, (void *) &oci_error, OCI_HTYPE_ERROR,
      /* user_data_size = */ 0, /* user_data = */ NULL);
  if (status != OCI_SUCCESS)
  {
    ERROR ("oracle plugin: OCIHandleAlloc (OCI_HTYPE_ERROR) failed "
        "with status %i.", status);
    return (-1);
  }

  return (0);
} /* }}} int o_init */
开发者ID:strizhechenko,项目名称:collectd,代码行数:32,代码来源:oracle.c

示例15: CheckLobType

int CheckLobType()
{
   OCIStmt *stmtlobtypehp;
   OCIDefine *defv1 = 0;
   char LobType[4];

   static text *stmt_lobtype  = (text *)"SELECT securefile from user_lobs where table_name='FOO' and column_name='DOCUMENT' ";

   LobType[3]='\0';

   CheckErr(errhp, OCIHandleAlloc(envhp, (dvoid **) &stmtlobtypehp,
                                     OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0));

   CheckErr(errhp, OCIStmtPrepare(stmtlobtypehp, errhp, (CONST text *) stmt_lobtype,
                                     strlen((char *) stmt_lobtype), OCI_NTV_SYNTAX, OCI_DEFAULT));

   CheckErr(errhp, OCIDefineByPos (stmtlobtypehp, (OCIDefine **) &defv1, errhp,
                         1, &LobType, 4, SQLT_STR,
                         (dvoid *)0, (ub2 *)0, (ub2 *)0, OCI_DEFAULT));

   CheckErr(errhp, OCIStmtExecute(svchp, stmtlobtypehp, errhp, (ub4) 1, (ub4) 0,
                                     (CONST OCISnapshot *) 0, (OCISnapshot *) 0, OCI_DEFAULT));
  if ( (strcmp(LobType, "YES")) == 0 ) 
     return (1) ;
  else
     return (0) ;

}
开发者ID:RicardoVivas,项目名称:oracle-scripts,代码行数:28,代码来源:LobUtilFunc.c


注:本文中的OCIHandleAlloc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。