Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 6AAA59FBAFB for ; Mon, 21 May 2007 01:41:24 -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 39328-04 for ; Mon, 21 May 2007 01:41:18 -0300 (ADT) X-Greylist: delayed 00:06:39.870696 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 5D0F29FB9AB for ; Mon, 21 May 2007 01:41:18 -0300 (ADT) Received: (qmail 65816 invoked from network); 21 May 2007 04:34:37 -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=Hus2uVv0QP4sjncgRWX/VgIwe+jbY0v60YOy4FX+f+dffN3UqjssYae3K6CFlXuC571Mf5M3gnUq02I73SCk4x71dwh9AYz6j0wZQimJbacGCwJQIJOCRi8afd4UL4NA2helgBEruD5/cJTi96ZidG/FmciPib8D4tmxTyEIl5o= ; 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:34:37 -0000 X-YMail-OSG: kaZ_ZqkVM1lk9lYC2SF2bjnqwg7o6c5g8DangSZMIL26kB9SwmDlMVJJBvU25u4zAA-- Message-ID: <46512118.2040105@rogers.com> Date: Mon, 21 May 2007 00:33:28 -0400 From: "Y. Ming Lam" User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: PQgetvalue failed to get non-text data under 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/56 X-Sequence-Number: 6563 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