• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ OCIAttrSet函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: open

	void open(const std::string& service, const std::string& username,
			const std::string& password, int mode)
	{
		if (OCIServerAttach(server, error, (text*) service.c_str(),
				service.length(), OCI_DEFAULT))
			throw_error();

		if (OCIAttrSet(svcctx, OCI_HTYPE_SVCCTX, server, 0, OCI_ATTR_SERVER,
				error))
			throw_error();

		if (OCIAttrSet(session, OCI_HTYPE_SESSION, (dvoid*) username.c_str(),
				username.length(), OCI_ATTR_USERNAME, error))
			throw_error();

		if (OCIAttrSet(session, OCI_HTYPE_SESSION, (dvoid*) password.c_str(),
				password.length(), OCI_ATTR_PASSWORD, error))
			throw_error();

		if (OCISessionBegin(svcctx, error, session, OCI_CRED_RDBMS, mode))
			throw_error();

		if (OCIAttrSet(svcctx, OCI_HTYPE_SVCCTX, session, 0, OCI_ATTR_SESSION,
				error))
			throw_error();
	}
开发者ID:purpleKarrot,项目名称:async-db,代码行数:26,代码来源:connection.hpp


示例2: _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


示例3: 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


示例4: 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


示例5: bind_string_post_bind_hook

static void bind_string_post_bind_hook(oci8_bind_t *obind)
{
    oci8_bind_string_t *obs = (oci8_bind_string_t *)obind;

    if (obs->charlen != 0) {
        chker2(OCIAttrSet(obind->base.hp.ptr, obind->base.type, (void*)&obs->charlen, 0, OCI_ATTR_MAXCHAR_SIZE, oci8_errhp),
               &obind->base);
    }
    chker2(OCIAttrSet(obind->base.hp.ptr, obind->base.type, (void*)&obs->csfrm, 0, OCI_ATTR_CHARSET_FORM, oci8_errhp),
           &obind->base);
}
开发者ID:Beerlover88,项目名称:ruby-oci8,代码行数:11,代码来源:bind.c


示例6: OCIInitialize

// Begins an Oracle session.
void OraSession::startSession(const std::string& sConnectAsUser, const std::string& sConnectAsUserPwd,
		const std::string& sConnectDBLink) 
{
	dvoid* tmp;
	sword status;

	status = OCIInitialize((ub4) OCI_THREADED | OCI_OBJECT, 0, 0, 0, 0);

	status = OCIHandleAlloc((dvoid *)NULL, (dvoid **)&ociHandles.envhp, (ub4)OCI_HTYPE_ENV, 52, (dvoid **)&tmp);

	status = OCIEnvInit(&ociHandles.envhp, (ub4)OCI_DEFAULT, 21, (dvoid **)&tmp);

	status = OCIHandleAlloc((dvoid *)ociHandles.envhp, (dvoid **)&ociHandles.errhp, (ub4)OCI_HTYPE_ERROR, 52, (dvoid **)&tmp);

	status = OCIHandleAlloc((dvoid *)ociHandles.envhp, (dvoid **)&ociHandles.srvhp, (ub4)OCI_HTYPE_SERVER, 52, (dvoid **)&tmp);

	if(checkerr(&ociHandles, OCIServerAttach(ociHandles.srvhp, ociHandles.errhp, (text *)sConnectDBLink.c_str(),
		(sb4)sConnectDBLink.length(), (ub4)OCI_DEFAULT)) != 0) {
		std::cout << "OCIServerAttach failed." << std::endl << std::endl;
		return;
	}

	status = OCIHandleAlloc((dvoid *)ociHandles.envhp, (dvoid **)&ociHandles.svchp, 
		(ub4)OCI_HTYPE_SVCCTX, 52, (dvoid **)&tmp);

	/* set attribute server context in the service context */
	status = OCIAttrSet((dvoid *) ociHandles.svchp, (ub4)OCI_HTYPE_SVCCTX, (dvoid *)ociHandles.srvhp, (ub4)0,
		(ub4)OCI_ATTR_SERVER, (OCIError *)ociHandles.errhp);

	/* allocate a user context handle */
	status = OCIHandleAlloc((dvoid *)ociHandles.envhp, (dvoid **)&ociHandles.usrhp, (ub4)OCI_HTYPE_SESSION, (size_t)0,
		(dvoid **)0);

	status = OCIAttrSet((dvoid *)ociHandles.usrhp, (ub4)OCI_HTYPE_SESSION, (dvoid *)sConnectAsUser.c_str(),
		(ub4)sConnectAsUser.length(), OCI_ATTR_USERNAME, ociHandles.errhp);

	status = OCIAttrSet((dvoid *)ociHandles.usrhp, (ub4)OCI_HTYPE_SESSION, (dvoid *)sConnectAsUserPwd.c_str(),
		(ub4)sConnectAsUserPwd.length(), OCI_ATTR_PASSWORD, ociHandles.errhp);

	if(checkerr(&ociHandles, OCISessionBegin(ociHandles.svchp, ociHandles.errhp, ociHandles.usrhp, OCI_CRED_RDBMS, OCI_DEFAULT)) != 0) {
		std::cout << "OCISessionBegin failed." << std::endl << std::endl;
		return;
	}

	status = OCIAttrSet((dvoid *)ociHandles.svchp, (ub4)OCI_HTYPE_SVCCTX, (dvoid *)ociHandles.usrhp, (ub4)0, OCI_ATTR_SESSION,
		ociHandles.errhp);

	status = OCIHandleAlloc((dvoid *)ociHandles.envhp, (dvoid **)&ociHandles.stmthp, (ub4)OCI_HTYPE_STMT, 50, (dvoid **)&tmp);

	connectedUser = sConnectAsUser;
}
开发者ID:Kangmo,项目名称:infinidb,代码行数:52,代码来源:orasession.cpp


示例7: 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


示例8: bind_lob_post_bind_hook_for_nclob

static void bind_lob_post_bind_hook_for_nclob(oci8_bind_t *obind)
{
    ub1 csfrm = SQLCS_NCHAR;

    chker2(OCIAttrSet(obind->base.hp.ptr, obind->base.type, (void*)&csfrm, 0, OCI_ATTR_CHARSET_FORM, oci8_errhp),
           &obind->base);
}
开发者ID:Captnwalker1,项目名称:ruby-oci8,代码行数:7,代码来源:lob.c


示例9: oci8_session_begin

/*
 * call-seq:
 *   session_begin(cred, mode)
 *
 * <b>internal use only</b>
 *
 * Begins the session by the OCI function OCISessionBegin().
 */
static VALUE oci8_session_begin(VALUE self, VALUE cred, VALUE mode)
{
    oci8_svcctx_t *svcctx = DATA_PTR(self);

    if (svcctx->logoff_strategy != &complex_logoff) {
        rb_raise(rb_eRuntimeError, "Use this method only for the service context handle created by OCI8#server_handle().");
    }
    if (svcctx->state & OCI8_STATE_SESSION_BEGIN_WAS_CALLED) {
        rb_raise(rb_eRuntimeError, "Could not use this method twice.");
    }

    /* check arguments */
    Check_Type(cred, T_FIXNUM);
    Check_Type(mode, T_FIXNUM);

    /* begin session */
    oci_lc(OCISessionBegin_nb(svcctx, svcctx->base.hp.ptr, oci8_errhp,
                              svcctx->usrhp, FIX2UINT(cred),
                              FIX2UINT(mode)));
    oci_lc(OCIAttrSet(svcctx->base.hp.ptr, OCI_HTYPE_SVCCTX,
                      svcctx->usrhp, 0, OCI_ATTR_SESSION,
                      oci8_errhp));
    svcctx->state |= OCI8_STATE_SESSION_BEGIN_WAS_CALLED;
    return Qnil;
}
开发者ID:jcasts,项目名称:ruby-oci8,代码行数:33,代码来源:oci8.c


示例10: OCI_CHECK_PTR

boolean OCI_API OCI_MsgSetSender
(
    OCI_Msg   *msg,
    OCI_Agent *sender
)
{
    boolean res = TRUE;

    OCI_CHECK_PTR(OCI_IPC_MSG, msg, FALSE);

    OCI_CALL2
    (
        res, msg->typinf->con,

        OCIAttrSet((dvoid *) msg->proph,
                   (ub4    ) OCI_DTYPE_AQMSG_PROPERTIES,
                   (dvoid *) (sender ? sender->handle : NULL),
                   (ub4    ) 0,
                   (ub4    ) OCI_ATTR_SENDER_ID,
                   msg->typinf->con->err)
    )

    OCI_RESULT(res);

    return res;
}
开发者ID:bradfordw,项目名称:prophet,代码行数:26,代码来源:msg.c


示例11: oci8_set_client_info

/*
 * call-seq:
 *   client_info = string or nil
 *
 * <b>(new in 2.0.3)</b>
 *
 * Sets additional information about the client application.
 * This information is stored in the V$SESSION view.
 *
 * === Oracle 10g client or upper
 *
 * This doesn't perform network round trips. The change is reflected
 * to the server by the next round trip such as OCI8#exec, OCI8#ping,
 * etc.
 *
 * === Oracle 9i client or lower
 *
 * This executes the following PL/SQL block internally.
 * The change is reflected immediately by a network round trip.
 *
 *   BEGIN
 *     DBMS_APPLICATION_INFO.SET_CLIENT_INFO(:client_info);
 *   END;
 *
 * See {Oracle Manual: Oracle Database PL/SQL Packages and Types Reference}[http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_appinf.htm#CHEJCFGG]
 */
static VALUE oci8_set_client_info(VALUE self, VALUE val)
{
    char *ptr;
    ub4 size;

    if (!NIL_P(val)) {
        OCI8SafeStringValue(val);
        ptr = RSTRING_PTR(val);
        size = RSTRING_LEN(val);
    } else {
        ptr = "";
        size = 0;
    }
    if (oracle_client_version >= ORAVER_10_1) {
        /* Oracle 10g or upper */
        oci_lc(OCIAttrSet(oci8_get_oci_session(self), OCI_HTYPE_SESSION, ptr,
                          size, OCI_ATTR_CLIENT_INFO, oci8_errhp));
    } else {
        /* Oracle 9i or lower */
        oci8_exec_sql_var_t bind_vars[1];

        /* :client_info */
        bind_vars[0].valuep = ptr;
        bind_vars[0].value_sz = size;
        bind_vars[0].dty = SQLT_CHR;
        bind_vars[0].indp = NULL;
        bind_vars[0].alenp = NULL;

        oci8_exec_sql(oci8_get_svcctx(self), 
                      "BEGIN\n"
                      "  DBMS_APPLICATION_INFO.SET_CLIENT_INFO(:client_info);\n"
                      "END;\n", 0, NULL, 1, bind_vars, 1);
    }
    return val;
}
开发者ID:jcasts,项目名称:ruby-oci8,代码行数:61,代码来源:oci8.c


示例12: oci8_server_attach

/*
 * call-seq:
 *   server_attach(dbname, mode)
 *
 * <b>internal use only</b>
 *
 * Attachs to the server by the OCI function OCIServerAttach().
 */
static VALUE oci8_server_attach(VALUE self, VALUE dbname, VALUE mode)
{
    oci8_svcctx_t *svcctx = oci8_get_svcctx(self);

    if (svcctx->logoff_strategy != &complex_logoff) {
        rb_raise(rb_eRuntimeError, "Use this method only for the service context handle created by OCI8#server_handle().");
    }
    if (svcctx->state & OCI8_STATE_SERVER_ATTACH_WAS_CALLED) {
        rb_raise(rb_eRuntimeError, "Could not use this method twice.");
    }

    /* check arguments */
    if (!NIL_P(dbname)) {
        OCI8SafeStringValue(dbname);
    }
    Check_Type(mode, T_FIXNUM);

    /* attach to the server */
    oci_lc(OCIServerAttach_nb(svcctx, svcctx->srvhp, oci8_errhp,
                              NIL_P(dbname) ? NULL : RSTRING_ORATEXT(dbname),
                              NIL_P(dbname) ? 0 : RSTRING_LEN(dbname),
                              FIX2UINT(mode)));
    oci_lc(OCIAttrSet(svcctx->base.hp.ptr, OCI_HTYPE_SVCCTX,
                      svcctx->srvhp, 0, OCI_ATTR_SERVER,
                      oci8_errhp));
    svcctx->state |= OCI8_STATE_SERVER_ATTACH_WAS_CALLED;
    return self;
}
开发者ID:jcasts,项目名称:ruby-oci8,代码行数:36,代码来源:oci8.c


示例13: conn_execute

/*
** Execute an SQL statement.
** Return a Cursor object if the statement is a query, otherwise
** return the number of tuples affected by the statement.
*/
static int conn_execute (lua_State *L) {
	env_data *env;
	conn_data *conn = getconnection (L);
	const char *statement = luaL_checkstring (L, 2);
	sword status;
	ub4 prefetch = 0;
	ub4 iters;
	ub4 mode;
	ub2 type;
	OCIStmt *stmthp;

	/* get environment */
	lua_rawgeti (L, LUA_REGISTRYINDEX, conn->env);
	if (!lua_isuserdata (L, -1))
		luaL_error(L,LUASQL_PREFIX"invalid environment in connection!");
	env = (env_data *)lua_touserdata (L, -1);
	/* statement handle */
	ASSERT (L, OCIHandleAlloc ((dvoid *)env->envhp, (dvoid **)&stmthp,
		OCI_HTYPE_STMT, (size_t)0, (dvoid **)0), conn->errhp);
	ASSERT (L, OCIAttrSet ((dvoid *)stmthp, (ub4)OCI_HTYPE_STMT,
		(dvoid *)&prefetch, (ub4)0, (ub4)OCI_ATTR_PREFETCH_ROWS,
		conn->errhp), conn->errhp);
	ASSERT (L, OCIStmtPrepare (stmthp, conn->errhp, (text *)statement,
		(ub4) strlen(statement), (ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT),
		conn->errhp);
	/* statement type */
	ASSERT (L, OCIAttrGet ((dvoid *)stmthp, (ub4) OCI_HTYPE_STMT,
		(dvoid *)&type, (ub4 *)0, (ub4)OCI_ATTR_STMT_TYPE, conn->errhp),
		conn->errhp);
	if (type == OCI_STMT_SELECT)
		iters = 0;
	else
		iters = 1;
	if (conn->auto_commit)
		mode = OCI_COMMIT_ON_SUCCESS;
	else
		mode = OCI_DEFAULT;
	/* execute statement */
	status = OCIStmtExecute (conn->svchp, stmthp, conn->errhp, iters,
		(ub4)0, (CONST OCISnapshot *)NULL, (OCISnapshot *)NULL, mode);
	if (status && (status != OCI_NO_DATA)) {
		OCIHandleFree ((dvoid *)stmthp, OCI_HTYPE_STMT);
		return checkerr (L, status, conn->errhp);
	}
	if (type == OCI_STMT_SELECT) {
		/* create cursor */
		return create_cursor (L, 1, conn, stmthp, statement);
	} else {
		/* return number of rows */
		int rows_affected;
		ASSERT (L, OCIAttrGet ((dvoid *)stmthp, (ub4)OCI_HTYPE_STMT,
			(dvoid *)&rows_affected, (ub4 *)0,
			(ub4)OCI_ATTR_ROW_COUNT, conn->errhp), conn->errhp);
		OCIHandleFree ((dvoid *)stmthp, OCI_HTYPE_STMT);
		lua_pushnumber (L, rows_affected);
		return 1;
	}
}
开发者ID:Abyss116,项目名称:luaplus51-all,代码行数:63,代码来源:ls_oci8.c


示例14: oci_create_tns_seesion_pool

bool oci_create_tns_seesion_pool(const unsigned char * connect_str, const int connect_str_len,
                                 const unsigned char * user_name, const int user_name_len,
                                 const unsigned char * password, const int password_len,
                                 const unsigned char * options, const int options_len)
{
    function_success = SUCCESS;
    poolName = NULL;
    poolNameLen = 0;

    oci_free_session_pool();

    /* allocate session pool handle
     * note: for OCIHandleAlloc() we check error on environment handle
     */
    checkenv(envhp, OCIHandleAlloc(envhp, (void **)&spoolhp,
                                   OCI_HTYPE_SPOOL, (size_t) 0, (void **) NULL));

    /* set the statement cache size for all sessions in the pool
     * note: this can also be set per session after obtaining the session from the pool
     */
    checkerr(errhp, OCIAttrSet(spoolhp, OCI_HTYPE_SPOOL,
                               &stmt_cachesize, 0, OCI_ATTR_SPOOL_STMTCACHESIZE, errhp));

    checkerr(errhp, OCISessionPoolCreate(envhp, errhp,
                                         spoolhp,
                                         (OraText **) &poolName, &poolNameLen,
                                         (OraText *) connect_str, connect_str_len,
                                         POOL_MIN, POOL_MAX, POOL_INCR,
                                         (OraText*)user_name, user_name_len,			/* homo pool user specified */
                                         (OraText*)password, password_len,			/* homo pool password specified */
                                         OCI_SPC_STMTCACHE));	/* modes */
    if(function_success != SUCCESS)return false;

    sprintf_s(session_pool_name, sizeof(session_pool_name), "%.*s", poolNameLen, (char *)poolName);

    ub1 spoolMode = OCI_SPOOL_ATTRVAL_NOWAIT;
    checkerr(errhp, OCIAttrSet(spoolhp, OCI_HTYPE_SPOOL,
                               (void*)&spoolMode, sizeof(ub1),
                               OCI_ATTR_SPOOL_GETMODE, errhp));
    if(function_success != SUCCESS)return false;

    return true;
}
开发者ID:c-bik,项目名称:erloci,代码行数:43,代码来源:oci_interface.cpp


示例15: OCI_CHECK_INITIALIZED

OCI_Transaction * OCI_API OCI_TransactionCreate
(
    OCI_Connection *con,
    unsigned int    timeout,
    unsigned int    mode,
    OCI_XID        *pxid
)
{
    OCI_Item *item         = NULL;
    OCI_Transaction *trans = NULL;
    boolean res            = TRUE;

    OCI_CHECK_INITIALIZED(NULL);

    OCI_CHECK_PTR(OCI_IPC_CONNECTION, con, NULL);

    /* create transaction object */

    item = OCI_ListAppend(con->trsns, sizeof(*trans));

    if (item != NULL)
    {
        trans = (OCI_Transaction *) item->data;

        trans->con     = con;
        trans->mode    = mode;
        trans->timeout = timeout;
        trans->local   = (pxid == NULL);

        /* allocate transaction handle */

        if (res == TRUE)
        {
            res = (OCI_SUCCESS == OCI_HandleAlloc((dvoid *) trans->con->env,
                                                  (dvoid **) (void *) &trans->htr,
                                                  (ub4) OCI_HTYPE_TRANS,
                                                  (size_t) 0, (dvoid **) NULL));
        }

        /* set XID attribute for global transaction */

        if (pxid != NULL)
        {
            memcpy(&trans->xid, pxid, sizeof(trans->xid));

            OCI_CALL2
            (
                res, con,

                OCIAttrSet((dvoid *) trans->htr, (ub4) OCI_HTYPE_TRANS,
                           (dvoid *) &trans->xid, (ub4) sizeof(trans->xid),
                           (ub4) OCI_ATTR_XID, trans->con->err)
            )
        }
开发者ID:Chaduke,项目名称:bah.mod,代码行数:54,代码来源:transaction.c


示例16: attr_set_binary

/*
 * call-seq:
 *   attr_set_binary(attr_type, attr_value)
 *
 * Sets the value of an attribute as `ub1 *' datatype.
 *
 * @param [Fixnum] attr_type
 * @param [String] attr_value
 * @return [self]
 *
 * @since 2.0.4
 * @private
 */
static VALUE attr_set_binary(VALUE self, VALUE attr_type, VALUE val)
{
    oci8_base_t *base = DATA_PTR(self);

    /* validate arguments */
    Check_Type(attr_type, T_FIXNUM);
    SafeStringValue(val);
    /* set attribute */
    chker2(OCIAttrSet(base->hp.ptr, base->type, RSTRING_PTR(val), RSTRING_LEN(val), FIX2INT(attr_type), oci8_errhp), base);
    return self;
}
开发者ID:afterthought,项目名称:ruby-oci8,代码行数:24,代码来源:ocihandle.c


示例17: attr_set_boolean

/*
 * call-seq:
 *   attr_set_boolean(attr_type, attr_value)
 *
 * Sets the value of an attribute as `boolean' datatype.
 *
 * @note If the specified attr_type's datatype is a
 *   pointer type, it causes a segmentation fault.
 *
 * @param [Fixnum] attr_type
 * @param [true or false] attr_value
 * @return [self]
 *
 * @since 2.0.4
 * @private
 */
static VALUE attr_set_boolean(VALUE self, VALUE attr_type, VALUE val)
{
    oci8_base_t *base = DATA_PTR(self);
    boolean value;

    /* validate arguments */
    Check_Type(attr_type, T_FIXNUM);
    value = RTEST(val) ? TRUE : FALSE;
    /* set attribute */
    chker2(OCIAttrSet(base->hp.ptr, base->type, &value, sizeof(value), FIX2INT(attr_type), oci8_errhp), base);
    return self;
}
开发者ID:afterthought,项目名称:ruby-oci8,代码行数:28,代码来源:ocihandle.c


示例18: attr_set_integer

/*
 * call-seq:
 *   attr_set_integer(attr_type, number)
 *
 * Sets the value of an attribute as `ub1 *' datatype.
 * +number+ is converted to internal Oracle NUMBER format before
 * it is set.
 *
 * @param [Fixnum] attr_type
 * @param [Numeric] number
 * @return [self]
 *
 * @since 2.0.4
 * @private
 */
static VALUE attr_set_integer(VALUE self, VALUE attr_type, VALUE val)
{
    oci8_base_t *base = DATA_PTR(self);
    OCINumber value;

    /* validate arguments */
    Check_Type(attr_type, T_FIXNUM);
    oci8_set_integer(&value, val, oci8_errhp);
    /* set attribute */
    chker2(OCIAttrSet(base->hp.ptr, base->type, &value, sizeof(value), FIX2INT(attr_type), oci8_errhp), base);
    return self;
}
开发者ID:afterthought,项目名称:ruby-oci8,代码行数:27,代码来源:ocihandle.c


示例19: attr_set_sb2

/*
 * call-seq:
 *   attr_set_sb2(attr_type, attr_value)
 *
 * Sets the value of an attribute as `sb2' datatype.
 *
 * @note If the specified attr_type's datatype is a
 *  pointer type, it causes a segmentation fault.
 *
 * @param [Fixnum] attr_type
 * @param [Fixnum] attr_value
 * @return [self]
 *
 * @since 2.0.4
 * @private
 */
static VALUE attr_set_sb2(VALUE self, VALUE attr_type, VALUE val)
{
    oci8_base_t *base = DATA_PTR(self);
    sb2 value;

    /* validate arguments */
    Check_Type(attr_type, T_FIXNUM);
    value = (sb2)check_data_range(val, SHRT_MIN, SHRT_MAX, "sb2");
    /* set attribute */
    chker2(OCIAttrSet(base->hp.ptr, base->type, &value, sizeof(value), FIX2INT(attr_type), oci8_errhp), base);
    return self;
}
开发者ID:afterthought,项目名称:ruby-oci8,代码行数:28,代码来源:ocihandle.c


示例20: attr_set_ub8

/*
 * call-seq:
 *   attr_set_ub8(attr_type, attr_value)
 *
 * Sets the value of an attribute as `ub8' datatype.
 *
 * @note If the specified attr_type's datatype is a
 *   pointer type, it causes a segmentation fault.
 *
 * @param [Fixnum] attr_type
 * @param [Integer] attr_value
 * @return [self]
 *
 * @since 2.0.4
 * @private
 */
static VALUE attr_set_ub8(VALUE self, VALUE attr_type, VALUE val)
{
    oci8_base_t *base = DATA_PTR(self);
    ub8 value;

    /* validate arguments */
    Check_Type(attr_type, T_FIXNUM);
    value = NUM2ULL(val);
    /* set attribute */
    chker2(OCIAttrSet(base->hp.ptr, base->type, &value, sizeof(value), FIX2INT(attr_type), oci8_errhp), base);
    return self;
}
开发者ID:afterthought,项目名称:ruby-oci8,代码行数:28,代码来源:ocihandle.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ OCIErrorGet函数代码示例发布时间:2022-05-30
下一篇:
C++ OCFS2_SB函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap