how do I get arbitrary sql results as strings in C

From: adb <adb(at)Beast(dot)COM>
To: pgsql-general(at)postgresql(dot)org
Subject: how do I get arbitrary sql results as strings in C
Date: 2001-02-24 01:07:14
Message-ID: Pine.GSO.4.10.10102231703540.2561-100000@hairdini.beast.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Is there an easy way in libpq to get the results from
any query as strings.

Imagine a cgi where you input any query and then it prints
out the rows returned

Something like this example of mysql code:

// fetch each row using mysql_fetch_row
MYSQL_ROW row;
unsigned int num_fields;

if( sql_result ) {
num_fields = mysql_num_fields( sql_result );

while( ( row = mysql_fetch_row( sql_result ) ) ) {

outputBuf_.print( L"<r>" );
for( unsigned int i = 0; i < num_fields ; i++ ) {
char * rowVal = row[i];
if( !rowVal ) {
rowVal = "";
}

outputBuf_.print( L"<c>%a</c>", rowVal );
}
outputBuf_.print( L"</r>\n" );
}
}

Thanks,

Alex.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message adb 2001-02-24 02:55:53 Re: how do I get arbitrary sql results as strings in C
Previous Message Sipos Andras 2001-02-23 22:52:17 Encoding: LATIN2 (hungary)