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 A7E59D1B4FB for ; Mon, 27 Oct 2003 07:26:38 +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 91866-09 for ; Mon, 27 Oct 2003 03:26:08 -0400 (AST) Received: from wind.ukr.net (wind.ukr.net [212.42.64.10]) by svr1.postgresql.org (Postfix) with ESMTP id 1D3E2D1B515 for ; Mon, 27 Oct 2003 03:26:06 -0400 (AST) Received: from 82-28.odessa.dialup.ukr.net ([212.42.82.28]) by wind.ukr.net with esmtp ID 1AE1lF-000Gt5-Gr ; Mon, 27 Oct 2003 09:26:00 +0200 From: Igor Shevchenko To: Tomasz Myrta Subject: Re: LIBPQ Question Date: Mon, 27 Oct 2003 09:25:25 +0200 User-Agent: KMail/1.5.2 References: <3F9CC61C.8010103@klaster.net> In-Reply-To: <3F9CC61C.8010103@klaster.net> Cc: pgsql-interfaces@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200310270925.26056.igor@carcass.ath.cx> X-HOSTING.UKR.NET-ID: c0a013d97ea9b9470e2e2466d3332ab4 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/53 X-Sequence-Number: 4542 On Monday 27 October 2003 09:15, Tomasz Myrta wrote: > 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(...)) Not true anymore with protocol v3, which added the binary format. Text format is still the default. > 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 > > > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if your > joining column's datatypes do not match -- Best regards, Igor Shevchenko