PQgetvalues的用法

来源:互联网 发布:知的拼音怎么写 编辑:程序博客网 时间:2024/04/30 10:59

if you ain't using binary type cursor, you've to do the
transform youself, I think should be:
...
int4 field;
...
field = atoi(PQgetvalue(,,,));
...
int http://www.linuxforum.net/books/pgsql-cur-c/libpq-chapter20658.htm:
and there are some comment in the doc:
PQgetvalue 返回一个 PGresult 里面的一条记录的单独的一个数据域(字段)的值.记录和数据域索引
从 0 开始.

char* PQgetvalue(const PGresult *res,
int tup_num,
int field_num);

对大多数查询而言,PQgetvalue 返回的值是一个表示字段值的空(NULL)结尾的 ASCII 字符串.但是
如果 PQbinaryTuples() 为 1,PQgetvalue 返回的值就是该类型在后端服务器内部的二进制表现形式(但是
不包括尺寸字--如果数据域是变长的).这样,把数据转换成对应的 C 类型就是程序员的责任
了.PQgetvalue 返回的指针指向一个本身是 PGresult 结构的一部分的存储区域.我们不能更改它,并
且如果我们要在 PGresult 结构的生存期后还要使用它的话,我们必须显式的把该数值拷贝到其他存
储器中.
and in :http://www.linuxforum.net/books/pgsql-cur-c/libpq-chapter21161.htm
there are ASCII and binary example, pretty good. just see it.
good luck.

---
BitBIRD
-------
Some birds ain't mean to be caged