PQgetvalue failed to get non-text data under binary format

Поиск
Список
Период
Сортировка
От Y. Ming Lam
Тема PQgetvalue failed to get non-text data under binary format
Дата
Msg-id 46512118.2040105@rogers.com
обсуждение исходный текст
Ответы Re: PQgetvalue failed to get non-text data under binary format  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-interfaces
Hi,

I am new to PostgreSQL and tried using the libpq C library.  I can read 
a test table using PQgetvalue for text format, i.e. format = 0.  
However, when I experiment with using binary output format, I was unable 
to read anything else except result set fiend that is in char(x), 
varchar(x), i.e., character string data.

What have I done wrong?
  int *     pId; LPSTR pszName; double * pSalary;
  PGresult *pResult = PQexecParams(m_pConn, (LPCTSTR)strSelect, nParams,                 parmTypes, paramValues,
parmLengths,parmFormats, 1);
 
   pId = (int *)PQgetvalue(pResult, row, 0);   pszName = (LPSTR)PQgetvalue(pResult, row, 1);   pSalary = (double
*)PQgetvalue(pResult,row, 6);
 
   printf("id: %d name: %s salary: %f", *pId, pszName, *pSalary);     
What I got is as follow:

+ + + printing resultset, 2 rows, 8 columns
id: 167772160 name: Amy Who salary: 0.000000
id: 16777216 name: David Smith salary: 0.000000

Which supposed to return:
id: 10 name: Amy Who salary: 150000.00
id: 1  name: David Smith salary: 350000.00

Any help is greatly appreciated!

Jeff




В списке pgsql-interfaces по дате отправления:

Предыдущее
От: "Oliveiros Cristina"
Дата:
Сообщение: Question on NpgsqlParameter object
Следующее
От: "Francisco Figueiredo Jr."
Дата:
Сообщение: Res: Question on NpgsqlParameter object