X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 26CD8D1B4F9 for ; Mon, 27 Oct 2003 07:16:43 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 91171-10 for ; Mon, 27 Oct 2003 03:16:13 -0400 (AST) Received: from serwer.skawsoft.com.pl (serwer.skawsoft.com.pl [213.25.37.66]) by svr1.postgresql.org (Postfix) with ESMTP id EA662D1B4E1 for ; Mon, 27 Oct 2003 03:16:11 -0400 (AST) Received: from klaster.net (core-1.citynet.pl [80.48.135.69]) by serwer.skawsoft.com.pl (Postfix) with ESMTP id C11912B3CB; Mon, 27 Oct 2003 08:15:05 +0100 (CET) Message-ID: <3F9CC61C.8010103@klaster.net> Date: Mon, 27 Oct 2003 08:15:40 +0100 From: Tomasz Myrta User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; rv:1.5) Gecko/20030916 X-Accept-Language: pl, en-us, en MIME-Version: 1.0 To: creid Cc: pgsql-interfaces@postgresql.org Subject: Re: LIBPQ Question References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/52 X-Sequence-Number: 4541 Dnia 2003-10-27 00:08, Użytkownik creid napisał: > Problem: Assigning a COUNT(*) result into an integer variable in my C > program consistently fails except when I assign the same result to a char > variable. I can only assume that the internal data type the COUNT function > uses is integer. > > Can anyone help put me in the proper mindset so I may deal with this, > seemingly simple issue, to resolution. > > I need the integer result to to help me satisfy a dynamic memory > requirement... COUNT(*) result will tell me how many rows of data I need to > malloc and I cannot perform a math operation on a char variable. All libpq results are strings. some_int_value=atoi(PQgetvalue(...)) Anyway why do you need count(*) ? When you retrieve your rows, you can always check how many are them using PQntuples(...) and then malloc your memory tables. Regards, Tomasz Myrta