postgres 数据库 求助 请问如下语句:select sum(money) from table;如何取得计算出来的值 。c libpq 接口 用哪个API 谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 呵呵,帖一段给你参考,具体还要看手册:PGconn * connection, const char * query_text PGresult * result; 97 if(( result = PQexec( connection, query_text )) == NULL ) 98 { 99 printf( "%s\n", PQerrorMessage( connection ));100 return;101 }102103 if( PQresultStatus( result ) == PGRES_TUPLES_OK )104 {105 print_result_set( result );106 }17 void print_result_set( PGresult * result ) 18 { 19 int col; 20 int row; 21 int * sizes; 22 23 /* 24 ** Compute the size for each column 25 */ 26 sizes = (int *)calloc( PQnfields( result ), sizeof( int )); 27 28 for( col = 0; col < PQnfields( result ); col++ ) 29 { 30 int len = 0; 31 32 for( row = 0; row < PQntuples( result ); row++ ) 33 { 34 if( PQgetisnull( result, row, col )) 35 len = 0; 36 else 37 len = PQgetlength( result, row, col ); 38 39 if( len > sizes[col] ) 40 sizes[col] = len; 41 } 42 43 if(( len = strlen( PQfname( result, col ))) > sizes[col] ) 44 sizes[col] = len; 45 46 if( sizes[col] > MAX_PRINT_LEN ) 47 sizes[col] = MAX_PRINT_LEN; 48 } 上边的参考代码还不够吗?PQexecPQresultStatusPQnfieldsPQntuples就这几个api啊。 mysql 数据库服务崩溃。大侠帮忙! mysql_thread_end调用死锁 mysql存储过程 .net 连接MySql数据库的问题 求一条SQL语句!块急死了! 你能搞定吗?有信心和把握的请进! 请教:mysql创建表的语法 那里有关于Spider技术的介绍? 帮你轻轻松松读完重点大学计算机系课程 多表连接查询效率 Mysql GUI Tools连接问题? 想请问一个排序的问题
PGconn * connection, const char * query_text
PGresult * result; 97 if(( result = PQexec( connection, query_text )) == NULL )
98 {
99 printf( "%s\n", PQerrorMessage( connection ));
100 return;
101 }
102
103 if( PQresultStatus( result ) == PGRES_TUPLES_OK )
104 {
105 print_result_set( result );
106 }17 void print_result_set( PGresult * result )
18 {
19 int col;
20 int row;
21 int * sizes;
22
23 /*
24 ** Compute the size for each column
25 */
26 sizes = (int *)calloc( PQnfields( result ), sizeof( int ));
27
28 for( col = 0; col < PQnfields( result ); col++ )
29 {
30 int len = 0;
31
32 for( row = 0; row < PQntuples( result ); row++ )
33 {
34 if( PQgetisnull( result, row, col ))
35 len = 0;
36 else
37 len = PQgetlength( result, row, col );
38
39 if( len > sizes[col] )
40 sizes[col] = len;
41 }
42
43 if(( len = strlen( PQfname( result, col ))) > sizes[col] )
44 sizes[col] = len;
45
46 if( sizes[col] > MAX_PRINT_LEN )
47 sizes[col] = MAX_PRINT_LEN;
48 }
PQexec
PQresultStatus
PQnfields
PQntuples
就这几个api啊。