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


C++ pgresult_get函数代码示例

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


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

示例1: pgresult_cmd_status

/*
 * call-seq:
 *    res.cmd_status() -> String
 *
 * Returns the status string of the last query command.
 */
static VALUE
pgresult_cmd_status(VALUE self)
{
	VALUE ret = rb_tainted_str_new2(PQcmdStatus(pgresult_get(self)));
	ASSOCIATE_INDEX(ret, self);
	return ret;
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:13,代码来源:pg_result.c

示例2: pgresult_error_message

/*
 * call-seq:
 *    res.error_message() -> String
 *
 * Returns the error message of the command as a string.
 */
static VALUE
pgresult_error_message(VALUE self)
{
	VALUE ret = rb_tainted_str_new2(PQresultErrorMessage(pgresult_get(self)));
	ASSOCIATE_INDEX(ret, self);
	return ret;
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:13,代码来源:pg_result.c

示例3: pg_result_clear

/*
 * call-seq:
 *    res.clear() -> nil
 *
 * Clears the PG::Result object as the result of the query.
 */
VALUE
pg_result_clear(VALUE self)
{
	PQclear(pgresult_get(self));
	DATA_PTR(self) = NULL;
	return Qnil;
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:13,代码来源:pg_result.c

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

示例5: make_column_result_array

/*
 * Make a Ruby array out of the encoded values from the specified
 * column in the given result.
 */
static VALUE
make_column_result_array( VALUE self, int col )
{
	PGresult *result = pgresult_get( self );
	int rows = PQntuples( result );
	int i;
	VALUE val = Qnil;
	VALUE results = rb_ary_new2( rows );

	if ( col >= PQnfields(result) )
		rb_raise( rb_eIndexError, "no column %d in result", col );

	for ( i=0; i < rows; i++ ) {
		val = rb_tainted_str_new( PQgetvalue(result, i, col),
		                          PQgetlength(result, i, col) );

#ifdef M17N_SUPPORTED
		/* associate client encoding for text format only */
		if ( 0 == PQfformat(result, col) ) {
			ASSOCIATE_INDEX( val, self );
		} else {
			rb_enc_associate( val, rb_ascii8bit_encoding() );
		}
#endif

		rb_ary_store( results, i, val );
	}

	return results;
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:34,代码来源:pg_result.c

示例6: pgresult_getvalue

/*
 * call-seq:
 *    res.getvalue( tup_num, field_num )
 *
 * Returns the value in tuple number _tup_num_, field _field_num_,
 * or +nil+ if the field is +NULL+.
 */
static VALUE
pgresult_getvalue(VALUE self, VALUE tup_num, VALUE field_num)
{
	VALUE val;
	PGresult *result;
	int i = NUM2INT(tup_num);
	int j = NUM2INT(field_num);

	result = pgresult_get(self);
	if(i < 0 || i >= PQntuples(result)) {
		rb_raise(rb_eArgError,"invalid tuple number %d", i);
	}
	if(j < 0 || j >= PQnfields(result)) {
		rb_raise(rb_eArgError,"invalid field number %d", j);
	}
	if(PQgetisnull(result, i, j))
		return Qnil;
	val = rb_tainted_str_new(PQgetvalue(result, i, j),
				PQgetlength(result, i, j));

#ifdef M17N_SUPPORTED
	/* associate client encoding for text format only */
	if ( 0 == PQfformat(result, j) ) {
		ASSOCIATE_INDEX( val, self );
	} else {
		rb_enc_associate( val, rb_ascii8bit_encoding() );
	}
#endif

	return val;
}
开发者ID:danielcode,项目名称:ruby-pg,代码行数:38,代码来源:pg_result.c

示例7: pg_tmbc_fit_to_result

static VALUE
pg_tmbc_fit_to_result( VALUE self, VALUE result )
{
	int nfields;
	t_tmbc *this = DATA_PTR( self );
	t_typemap *default_tm;
	VALUE sub_typemap;

	nfields = PQnfields( pgresult_get(result) );
	if ( this->nfields != nfields ) {
		rb_raise( rb_eArgError, "number of result fields (%d) does not match number of mapped columns (%d)",
				nfields, this->nfields );
	}

	/* Ensure that the default type map fits equaly. */
	default_tm = DATA_PTR( this->typemap.default_typemap );
	sub_typemap = default_tm->funcs.fit_to_result( this->typemap.default_typemap, result );

	/* Did the default type return the same object ? */
	if( sub_typemap == this->typemap.default_typemap ){
		return self;
	} else {
		/* Our default type map built a new object, so we need to propagate it
		 * and build a copy of this type map and set it as default there.. */
		VALUE new_typemap = pg_tmbc_s_allocate( rb_cTypeMapByColumn );
		size_t struct_size = sizeof(t_tmbc) + sizeof(struct pg_tmbc_converter) * nfields;
		t_tmbc *p_new_typemap = (t_tmbc *)xmalloc(struct_size);

		memcpy( p_new_typemap, this, struct_size );
		p_new_typemap->typemap.default_typemap = sub_typemap;
		DATA_PTR(new_typemap) = p_new_typemap;
		return new_typemap;
	}
}
开发者ID:BrentonEarl,项目名称:Blotter,代码行数:34,代码来源:pg_type_map_by_column.c

示例8: pgresult_nparams

/*
 * call-seq:
 *    res.nparams() -> Fixnum
 *
 * Returns the number of parameters of a prepared statement.
 * Only useful for the result returned by conn.describePrepared
 */
static VALUE
pgresult_nparams(VALUE self)
{
	PGresult *result;

	result = pgresult_get(self);
	return INT2FIX(PQnparams(result));
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:15,代码来源:pg_result.c

示例9: pgresult_paramtype

/*
 * call-seq:
 *    res.paramtype( param_number ) -> Oid
 *
 * Returns the Oid of the data type of parameter _param_number_.
 * Only useful for the result returned by conn.describePrepared
 */
static VALUE
pgresult_paramtype(VALUE self, VALUE param_number)
{
	PGresult *result;

	result = pgresult_get(self);
	return INT2FIX(PQparamtype(result,NUM2INT(param_number)));
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:15,代码来源:pg_result.c

示例10: pg_result_clear

/*
 * call-seq:
 *    res.clear() -> nil
 *
 * Clears the PG::Result object as the result of the query.
 *
 * If PG::Result#autoclear? is true then the result is marked as cleared
 * and the underlying C struct will be cleared automatically by libpq.
 *
 */
VALUE
pg_result_clear(VALUE self)
{
	t_pg_result *this = pgresult_get_this(self);
	if( !this->autoclear )
		PQclear(pgresult_get(self));
	this->pgresult = NULL;
	return Qnil;
}
开发者ID:RapsIn4,项目名称:pg,代码行数:19,代码来源:pg_result.c

示例11: pgresult_oid_value

/*
 * call-seq:
 *    res.oid_value() -> Fixnum
 *
 * Returns the +oid+ of the inserted row if applicable,
 * otherwise +nil+.
 */
static VALUE
pgresult_oid_value(VALUE self)
{
	Oid n = PQoidValue(pgresult_get(self));
	if (n == InvalidOid)
		return Qnil;
	else
		return INT2FIX(n);
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:16,代码来源:pg_result.c

示例12: pgresult_ftype

/*
 * call-seq:
 *    res.ftype( column_number )
 *
 * Returns the data type associated with _column_number_.
 *
 * The integer returned is the internal +OID+ number (in PostgreSQL)
 * of the type. To get a human-readable value for the type, use the
 * returned OID and the field's #fmod value with the format_type() SQL
 * function:
 *
 *   # Get the type of the second column of the result 'res'
 *   typename = conn.
 *     exec( "SELECT format_type($1,$2)", [res.ftype(1), res.fmod(1)] ).
 *     getvalue( 0, 0 )
 *
 * Raises an ArgumentError if _column_number_ is out of range.
 */
static VALUE
pgresult_ftype(VALUE self, VALUE index)
{
	PGresult* result = pgresult_get(self);
	int i = NUM2INT(index);
	if (i < 0 || i >= PQnfields(result)) {
		rb_raise(rb_eArgError, "invalid field number %d", i);
	}
	return INT2NUM(PQftype(result, i));
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:28,代码来源:pg_result.c

示例13: pgresult_each

/*
 * call-seq:
 *    res.each{ |tuple| ... }
 *
 * Invokes block for each tuple in the result set.
 */
static VALUE
pgresult_each(VALUE self)
{
	PGresult *result = pgresult_get(self);
	int tuple_num;

	for(tuple_num = 0; tuple_num < PQntuples(result); tuple_num++) {
		rb_yield(pgresult_aref(self, INT2NUM(tuple_num)));
	}
	return self;
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:17,代码来源:pg_result.c

示例14: pgresult_fformat

/*
 * call-seq:
 *    res.fformat( column_number ) -> Fixnum
 *
 * Returns the format (0 for text, 1 for binary) of column
 * _column_number_.
 *
 * Raises ArgumentError if _column_number_ is out of range.
 */
static VALUE
pgresult_fformat(VALUE self, VALUE column_number)
{
	PGresult *result = pgresult_get(self);
	int fnumber = NUM2INT(column_number);
	if (fnumber < 0 || fnumber >= PQnfields(result)) {
		rb_raise(rb_eArgError, "Column number is out of range: %d",
			fnumber);
	}
	return INT2FIX(PQfformat(result, fnumber));
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:20,代码来源:pg_result.c

示例15: pgresult_field_values

/*
 *  call-seq:
 *     res.field_values( field )   -> array
 *
 *  Returns an Array of the values from the given _field_ of each tuple in the result.
 *
 */
static VALUE
pgresult_field_values( VALUE self, VALUE field )
{
	PGresult *result = pgresult_get( self );
	const char *fieldname = StringValuePtr( field );
	int fnum = PQfnumber( result, fieldname );

	if ( fnum < 0 )
		rb_raise( rb_eIndexError, "no such field '%s' in result", fieldname );

	return make_column_result_array( self, fnum );
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:19,代码来源:pg_result.c


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