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

C++ PQcmdTuples函数代码示例

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

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



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

示例1: SWITCH_DECLARE

SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_finish_results_real(const char* file, const char* func, int line, switch_pgsql_handle_t *handle)
{
#ifdef SWITCH_HAVE_PGSQL
    switch_pgsql_result_t *res = NULL;
    switch_pgsql_status_t final_status = SWITCH_PGSQL_SUCCESS;
    int done = 0;
    do {
        switch_pgsql_next_result(handle, &res);
        if (res && res->err && !switch_stristr("already exists", res->err) && !switch_stristr("duplicate key name", res->err)) {
            switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "Error executing query:\n%s\n", res->err);
            final_status = SWITCH_PGSQL_FAIL;
        }

        if (!res) {
            done = 1;
        } else if (res->result) {
            char *affected_rows = PQcmdTuples(res->result);

            if (!zstr(affected_rows)) {
                handle->affected_rows = atoi(affected_rows);
            }
        }

        switch_pgsql_free_result(&res);
    } while (!done);
    return final_status;
#else
    return SWITCH_PGSQL_FAIL;
#endif
}
开发者ID:odmanV2,项目名称:freecenter,代码行数:30,代码来源:switch_pgsql.c


示例2: pgresult_cmd_tuples

/*
 * call-seq:
 *    res.cmd_tuples() -> Fixnum
 *
 * Returns the number of tuples (rows) affected by the SQL command.
 *
 * If the SQL command that generated the PG::Result was not one of:
 * * +INSERT+
 * * +UPDATE+
 * * +DELETE+
 * * +MOVE+
 * * +FETCH+
 * or if no tuples were affected, <tt>0</tt> is returned.
 */
static VALUE
pgresult_cmd_tuples(VALUE self)
{
	long n;
	n = strtol(PQcmdTuples(pgresult_get(self)),NULL, 10);
	return INT2NUM(n);
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:21,代码来源:pg_result.c


示例3: pgsqlExecute

static HB_ERRCODE pgsqlExecute( SQLDDCONNECTION * pConnection, PHB_ITEM pItem )
{
   PGconn *       pConn = ( ( SDDCONN * ) pConnection->pSDDConn )->pConn;
   int            iTuples;
   PGresult *     pResult;
   ExecStatusType status;
   unsigned long  ulAffectedRows;

   pResult = PQexec( pConn, hb_itemGetCPtr( pItem ) );
   if( ! pResult )
   {
      hb_rddsqlSetError( 1, PQerrorMessage( pConn ), hb_itemGetCPtr( pItem ), NULL, 0 );
      return HB_FAILURE;
   }

   status = PQresultStatus( pResult );
   if( status != PGRES_TUPLES_OK && status != PGRES_COMMAND_OK )
   {
      hb_rddsqlSetError( status, PQresultErrorMessage( pResult ), hb_itemGetCPtr( pItem ), NULL, 0 );
      return HB_FAILURE;
   }

   iTuples = PQntuples( pResult );
   if( iTuples > 0 )
      ulAffectedRows = ( unsigned long ) iTuples;
   else
      ulAffectedRows = ( unsigned long ) atol( PQcmdTuples( pResult ) );

   hb_rddsqlSetError( 0, NULL, hb_itemGetCPtr( pItem ), NULL, ulAffectedRows );
   PQclear( pResult );
   return HB_SUCCESS;
}
开发者ID:ggargano,项目名称:hbtest2,代码行数:32,代码来源:sddpg.c


示例4: encode_result

void encode_result(ei_x_buff* x, PGresult* res, PGconn* conn)
{
    int row, n_rows, col, n_cols;
    switch (PQresultStatus(res)) {
    case PGRES_TUPLES_OK: 
	n_rows = PQntuples(res); 
	n_cols = PQnfields(res); 
	ei_x_encode_tuple_header(x, 2);
	encode_ok(x);
	ei_x_encode_list_header(x, n_rows+1);
 	ei_x_encode_list_header(x, n_cols);
	for (col = 0; col < n_cols; ++col) {
	    ei_x_encode_string(x, PQfname(res, col));
	}
	ei_x_encode_empty_list(x); 
	for (row = 0; row < n_rows; ++row) {
	    ei_x_encode_list_header(x, n_cols);
	    for (col = 0; col < n_cols; ++col) {
		ei_x_encode_string(x, PQgetvalue(res, row, col));
	    }
	    ei_x_encode_empty_list(x);
	}
	ei_x_encode_empty_list(x); 
	break; 
    case PGRES_COMMAND_OK:
	ei_x_encode_tuple_header(x, 2);
        encode_ok(x);
	ei_x_encode_string(x, PQcmdTuples(res));
        break;
    default:
	encode_error(x, conn);
	break;
    }
}
开发者ID:Dasudian,项目名称:otp,代码行数:34,代码来源:pg_encode.c


示例5: pq_cmdtuples

/* ML type : pgresult_ -> int */
EXTERNML value pq_cmdtuples(value pgresval) 
{
  const char* s = PQcmdTuples(PGresult_val(pgresval));
  if (s == NULL)
    failwith("pq_cmdtuples");    
  return Val_long(atoi(s));
}
开发者ID:Athas,项目名称:mosml,代码行数:8,代码来源:mpq.c


示例6: va_start

    unsigned long psMysqlConnection::Command(const char *sql,...)
    {
        psStopWatch timer;
        csString querystr;
        va_list args;

        va_start(args, sql);
        querystr.FormatV(sql, args);
        va_end(args);

        lastquery = querystr;

        timer.Start();
        PGresult *res = PQexec(conn, querystr.GetData());
        
        if(res && PQresultStatus(res) != PGRES_FATAL_ERROR)
        {
            if(timer.Stop() > 1000)
            {
                csString status;
                status.Format("SQL query %s, has taken %u time to process.\n", querystr.GetData(), timer.Stop());
                if(logcsv)
                    logcsv->Write(CSV_STATUS, status);
            }
            profs.AddSQLTime(querystr, timer.Stop());
            lastRow = PQoidValue(res);
            const char *const RowsStr = PQcmdTuples(res);
            return (unsigned long) (RowsStr[0] ? atoi(RowsStr) : 0);
        }
        else
        {
            PQclear(res);
            return QUERY_FAILED;
        }
    }
开发者ID:Mixone-FinallyHere,项目名称:planeshift,代码行数:35,代码来源:dal.cpp


示例7: KCSQLResultBase

PgSQLResult::PgSQLResult(PgSQLConnection* pConnection, PGresult * sqlResult)
    : KCSQLResultBase(pConnection)
{
    m_sqlResult = sqlResult;
    if (m_sqlResult)
    {
        m_numRows = PQntuples(m_sqlResult);
        m_numFields = PQnfields(m_sqlResult);
        m_sqlRow = -1;

        for (int i = 0; i<m_numFields; ++i)
        {
            m_vName.push_back( PQfname(m_sqlResult, i) );
        }
        m_vValue.resize(m_numFields);
        const char* pszResult = PQcmdTuples(sqlResult);
        if (pszResult)
        {
            m_affectRowCount = atoi(pszResult);
        }
        Seek(0);
    }
    else
    {
        m_sqlRow = -1;
        m_numRows = 0;
        m_numFields = 0;
    }
}
开发者ID:lonsharn,项目名称:lsh_server,代码行数:29,代码来源:kc_pgsql.cpp


示例8: pgsql_handle_doer

static zend_long pgsql_handle_doer(pdo_dbh_t *dbh, const char *sql, zend_long sql_len)
{
	pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data;
	PGresult *res;
	zend_long ret = 1;
	ExecStatusType qs;

	if (!(res = PQexec(H->server, sql))) {
		/* fatal error */
		pdo_pgsql_error(dbh, PGRES_FATAL_ERROR, NULL);
		return -1;
	}
	qs = PQresultStatus(res);
	if (qs != PGRES_COMMAND_OK && qs != PGRES_TUPLES_OK) {
		pdo_pgsql_error(dbh, qs, pdo_pgsql_sqlstate(res));
		PQclear(res);
		return -1;
	}
	H->pgoid = PQoidValue(res);
	if (qs == PGRES_COMMAND_OK) {
		ZEND_ATOL(ret, PQcmdTuples(res));
	} else {
		ret = Z_L(0);
	}
	PQclear(res);

	return ret;
}
开发者ID:mdesign83,项目名称:php-src,代码行数:28,代码来源:pgsql_driver.c


示例9: doSQL

void doSQL(PGconn *conn, char *command)
{
  PGresult *result;

  printf("%s\n", command);

  result = PQexec(conn, command);
  printf("status is %s\n", PQresStatus(PQresultStatus(result)));
  printf("#rows affected %s\n", PQcmdTuples(result));
  printf("result message: %s\n", PQresultErrorMessage(result));

  switch(PQresultStatus(result)) {
  case PGRES_TUPLES_OK:
    {
      int r, n;
      int nrows = PQntuples(result);
      int nfields = PQnfields(result);
      printf("number of rows returned = %d\n", nrows);
      printf("number of fields returned = %d\n", nfields);
      for(r = 0; r < nrows; r++) {
	for(n = 0; n < nfields; n++)
	  printf(" %s = %s(%d),", 
		 PQfname(result, n), 
		 PQgetvalue(result, r, n),
		 PQgetlength(result, r, n));
	printf("\n");
      }
    }
  }
  PQclear(result);
}
开发者ID:swistak,项目名称:skarbnik,代码行数:31,代码来源:select2.c


示例10: pgsql_update

static int pgsql_update(void *theconn, const Octstr *sql, List *binds)
{
    int	rows;
    PGresult *res = NULL;
    PGconn *conn = (PGconn*) theconn;

    res = PQexec(conn, octstr_get_cstr(sql));
    if (res == NULL)
        return -1;

    switch (PQresultStatus(res)) {
        case PGRES_BAD_RESPONSE:
        case PGRES_NONFATAL_ERROR:
        case PGRES_FATAL_ERROR:
            error(0, "PGSQL: %s", octstr_get_cstr(sql));
            error(0, "PGSQL: %s", PQresultErrorMessage(res));
            PQclear(res);
            return -1;
        default: /* for compiler please */
            break;
    }
    rows = atoi(PQcmdTuples(res));
    PQclear(res);

    return rows;
}
开发者ID:frese,项目名称:mbuni,代码行数:26,代码来源:dbpool_pgsql.c


示例11: PQexec

int PG::operacion(const char* query){
    PGresult *res = PQexec(conn,query);
    int x = atoi(PQcmdTuples(res));
    // Para obtener errores :
    // char* error = PQresultErrorField(res,PG_DIAG_SQLSTATE);
    PQclear(res);
    return x;
}
开发者ID:AndresRicardoTorres,项目名称:IPMPAIS,代码行数:8,代码来源:postgresql.cpp


示例12: process_result

static awk_value_t *
process_result(PGconn *conn, PGresult *res, awk_value_t *resp)
{
  ExecStatusType rc;

  switch (rc = PQresultStatus(res)) {
  case PGRES_TUPLES_OK:
    {
      static unsigned long hnum = 0;
      char handle[64];
      size_t sl;

      snprintf(handle, sizeof(handle), "TUPLES %d pgres%lu",
	       PQntuples(res), hnum++);
      sl = strlen(handle);
      strhash_get(results, handle, sl, 1)->data = res;
      make_string_malloc(handle, sl, resp);
    }
    break;
  case PGRES_COMMAND_OK:
  case PGRES_EMPTY_QUERY:
    {
      char result[32];
      int cnt;

      if (sscanf(PQcmdTuples(res), "%d", &cnt) != 1)
        cnt = 0;
      snprintf(result, sizeof(result), "OK %d", cnt);
      PQclear(res);
      make_string_malloc(result, strlen(result), resp);
    }
    break;
  case PGRES_COPY_IN:
    {
      char buf[100];
      snprintf(buf, sizeof(buf), "COPY_IN %d %s",
	       PQnfields(res), (PQbinaryTuples(res) ? "BINARY" : "TEXT"));
      make_string_malloc(buf, strlen(buf), resp);
      PQclear(res);
    }
    break;
  case PGRES_COPY_OUT:
    {
      char buf[100];
      snprintf(buf, sizeof(buf), "COPY_OUT %d %s",
	       PQnfields(res), (PQbinaryTuples(res) ? "BINARY" : "TEXT"));
      make_string_malloc(buf, strlen(buf), resp);
      PQclear(res);
    }
    break;
  default: /* error */
    set_error(conn, rc, resp);
    set_ERRNO(PQresultErrorMessage(res));
    PQclear(res);
  }
  return resp;
}
开发者ID:gvlx,项目名称:gawkextlib,代码行数:57,代码来源:pgsql.c


示例13: changed_tuples

    int changed_tuples() const {
      std::string t = PQcmdTuples(res);
      if (t.empty())
	throw Error::no_tuples("", conn.getName());
      std::stringstream s;
      s << t;
      int r;
      s >> r;
      return r;
    }
开发者ID:MGwynne,项目名称:oklibrary,代码行数:10,代码来源:DatabaseHandler01.hpp


示例14: PQcmdTuples

long PgQuery::affectedRows ()
{
  long res = 0;
  char *str_rows = PQcmdTuples (_res);
  if (!str_rows || !*str_rows)
    return res;
  if (sscanf (str_rows, "%ld", &res) != 1)
    return 0;
  return res;
}
开发者ID:Chugajstyr,项目名称:sams2,代码行数:10,代码来源:pgquery.cpp


示例15: evsql_result_affected

size_t evsql_result_affected (const struct evsql_result *res) {
    switch (res->evsql->type) {
        case EVSQL_EVPQ:
            // XXX: errors?
            return strtol(PQcmdTuples(res->result.pq), NULL, 10);

        default:
            FATAL("res->evsql->type");
    }
}
开发者ID:SpComb,项目名称:evsql,代码行数:10,代码来源:result.c


示例16: PQcmdTuples

// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
uint64_t PostgreSQLDatabase::numberOfAffectedRows() {
	char *number = PQcmdTuples(_result);
	if ( number == NULL || *number == '\0' )
		return (uint64_t)~0;

	uint64_t count;
	if ( sscanf(number, "%lud", &count) == 1 )
		return count;

	return (uint64_t)~0;
}
开发者ID:aemanov,项目名称:seiscomp3,代码行数:12,代码来源:postgresqldatabaseinterface.cpp


示例17: return

int ResultSet::getTupleCount(void)
{
	//In case the result has some tuples
	if(!empty_result)
		//Returns the tuple count gathered after the SQL command
		return(PQntuples(sql_result));
	else
		/* Returns the line amount that were affected by the SQL command
		 (only for INSERT, DELETE, UPDATE) */
		return(atoi(PQcmdTuples(sql_result)));
}
开发者ID:bgalok,项目名称:pgmodeler,代码行数:11,代码来源:resultset.cpp


示例18: Rows

	virtual int Rows()
	{
		if(!cols && !rows)
		{
			return atoi(PQcmdTuples(res));
		}
		else
		{
			return rows;
		}
	}
开发者ID:thepaul,项目名称:inspircd-deb,代码行数:11,代码来源:m_pgsql.cpp


示例19: do_postgres_cCommand_execute_non_query

VALUE do_postgres_cCommand_execute_non_query(int argc, VALUE *argv, VALUE self) {
  VALUE connection = rb_iv_get(self, "@connection");
  VALUE postgres_connection = rb_iv_get(connection, "@connection");

  if (postgres_connection == Qnil) {
    rb_raise(eDO_ConnectionError, "This connection has already been closed.");
  }

  VALUE query = data_objects_build_query_from_args(self, argc, argv);
  PGconn *db = DATA_PTR(postgres_connection);
  PGresult *response;
  int status;

  response = do_postgres_cCommand_execute(self, connection, db, query);
  status = PQresultStatus(response);

  VALUE affected_rows = Qnil;
  VALUE insert_id = Qnil;

  if (status == PGRES_TUPLES_OK) {
    if (PQgetlength(response, 0, 0) == 0) {
      insert_id = Qnil;
    }
    else {
      insert_id = INT2NUM(atoi(PQgetvalue(response, 0, 0)));
    }

    affected_rows = INT2NUM(atoi(PQcmdTuples(response)));
  }
  else if (status == PGRES_COMMAND_OK) {
    insert_id = Qnil;
    affected_rows = INT2NUM(atoi(PQcmdTuples(response)));
  }
  else {
    do_postgres_raise_error(self, response, query);
  }

  PQclear(response);
  return rb_funcall(cDO_PostgresResult, DO_ID_NEW, 3, self, affected_rows, insert_id);
}
开发者ID:Jpoehlman,项目名称:wildtrack,代码行数:40,代码来源:do_postgres.c


示例20: cCommand_execute_non_query

static VALUE cCommand_execute_non_query(int argc, VALUE *argv[], VALUE self) {
  VALUE connection = rb_iv_get(self, "@connection");
  VALUE postgres_connection = rb_iv_get(connection, "@connection");
  if (Qnil == postgres_connection) {
    rb_raise(eConnectionError, "This connection has already been closed.");
  }

  PGconn *db = DATA_PTR(postgres_connection);
  PGresult *response;
  int status;

  VALUE affected_rows = Qnil;
  VALUE insert_id = Qnil;

  VALUE query = build_query_from_args(self, argc, argv);

  response = cCommand_execute(self, db, query);

  status = PQresultStatus(response);

  if ( status == PGRES_TUPLES_OK ) {
    insert_id = INT2NUM(atoi(PQgetvalue(response, 0, 0)));
    affected_rows = INT2NUM(atoi(PQcmdTuples(response)));
  }
  else if ( status == PGRES_COMMAND_OK ) {
    insert_id = Qnil;
    affected_rows = INT2NUM(atoi(PQcmdTuples(response)));
  }
  else {
    raise_error(self, response, query);
  }

  PQclear(response);

  return rb_funcall(cResult, ID_NEW, 3, self, affected_rows, insert_id);
}
开发者ID:matthewd,项目名称:do,代码行数:36,代码来源:do_postgres_ext.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ PQconnectdb函数代码示例发布时间:2022-05-30
下一篇:
C++ PQclear函数代码示例发布时间: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