X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id E6341D1BB63; Thu, 21 Aug 2003 03:11:30 -0300 (ADT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 78215-09; Thu, 21 Aug 2003 03:11:16 -0300 (ADT) Received: from megazone.bigpanda.com (45.mufb.snfc.sffca01r18.dsl.att.net [12.103.249.45]) by svr1.postgresql.org (Postfix) with ESMTP id 1A7C6D1BAE7; Thu, 21 Aug 2003 03:11:11 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id B2437D62B; Wed, 20 Aug 2003 23:11:10 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 9FE025C11; Wed, 20 Aug 2003 23:11:10 -0700 (PDT) Date: Wed, 20 Aug 2003 23:11:10 -0700 (PDT) From: Stephan Szabo To: Anagha Joshi Cc: , , Subject: Re: URGENT : free result (libpq++ API) In-Reply-To: Message-ID: <20030820230649.P33044-100000@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/245 X-Sequence-Number: 9966 On Thu, 21 Aug 2003, Anagha Joshi wrote: > Hi all, > I'm using PG - 7.2.4 on Solaries. > I'm using "libpq++" library as client implementation is coded in "C++". > > I'm doing the following : > 1. Making the connection to database by creating new object of > "PgDatabase" i.e. > data = new PgDatabase( " CONNECTION INFO "); > > 2. Then I execure the query with: > int return = data->Exec( " THIS IS A SQL QUERY"); > > My question is , > How should I clear(free) the result of the query? Need I close the > connection after each query to do that? It looks to me that PgConnection::Exec clears an existing query result when it's called. // PgConnection::exec -- send a query to the backend ExecStatusType PgConnection::Exec(const char* query) { // Clear the result stucture if needed if (pgResult) PQclear(pgResult); // Execute the given query pgResult = PQexec(pgConn, query); // Return the status if (pgResult) return PQresultStatus(pgResult); else return PGRES_FATAL_ERROR; }