Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 084159FB8BD for ; Mon, 21 May 2007 01:42:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 40275-01 for ; Mon, 21 May 2007 01:42:38 -0300 (ADT) X-Greylist: delayed 00:06:40.61145 by SQLgrey-1.7.5 Received: from smtp105.rog.mail.re2.yahoo.com (smtp105.rog.mail.re2.yahoo.com [206.190.36.83]) by postgresql.org (Postfix) with SMTP id 47E719FB9AB for ; Mon, 21 May 2007 01:42:38 -0300 (ADT) Received: (qmail 66781 invoked from network); 21 May 2007 04:35:57 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=rogers.com; h=Received:X-YMail-OSG:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Content-Transfer-Encoding; b=k3zr1wqPM6PiJi9W9bLJbMbiYkM5PO7Q/5nb0pzil5OYg6fojmM/M0ZrEW8C+K0VanB7bAXoEYisHAkfJ8/dF2ZGqkYmjK8EYQAGxPb9Z9VCAYf1untKAaifWhtnSRl9cSiQClnIMvT8AiKuJNoNR0Ppg95HT+bnPESKeHMInFY= ; Received: from unknown (HELO ?127.0.0.1?) (ymlam@rogers.com@99.246.131.154 with plain) by smtp105.rog.mail.re2.yahoo.com with SMTP; 21 May 2007 04:35:56 -0000 X-YMail-OSG: igpKwxAVM1mhs5iTLnLnQPmSdzK0TsnqV33aPoQSYek0imZvZb5BWN98rf26DOUu3g-- Message-ID: <4651216B.2060707@rogers.com> Date: Mon, 21 May 2007 00:34:51 -0400 From: Jeff Lynn User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: PQgetvalue failed to return column value for non-text data in binary format Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.723 tagged_above=0 required=5 tests=BAYES_40=-0.185, DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_POST=1.708 X-Spam-Level: * X-Archive-Number: 200705/37 X-Sequence-Number: 6544 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