Received: from antares.mcs.anl.gov (mcs.anl.gov [140.221.9.6]) by hub.org (8.9.1/8.9.1) with SMTP id SAA10356 for ; Mon, 23 Nov 1998 18:07:10 -0500 (EST) (envelope-from selkovjr@mcs.anl.gov) Received: from mcs.anl.gov (selkovjr@selkovjr.xnet.com [205.243.141.67]) by antares.mcs.anl.gov (8.6.10/8.6.10) with ESMTP id RAA23573; Mon, 23 Nov 1998 17:06:57 -0600 Message-Id: <199811232306.RAA23573@antares.mcs.anl.gov> To: david@tte.tamu.edu, pgsql-interfaces@postgresql.org Subject: Re: [INTERFACES] Dereferencing PG_Result In-Reply-To: Your message of "Mon, 23 Nov 1998 09:52:46 CST." Date: Mon, 23 Nov 1998 18:08:23 -0500 From: "Gene Selkov Jr." > Here's the code: > > #!/usr/bin/perl > > use Pg > > $conn = Pg::connectdb("dbname = mydb"); > $result = $conn->exec("select * from mytable"); > > print $result "\n"; > > ----end code--- > > This is what's returned: > > PG_results=SCALAR(0x8110e14) > > ----end result----- > Mydb has a table mytable with a field myfield. There are two tuples. > > Question: How can I deference the pointer to get at the actual data? if ( $result->ntuples > 0 ) { for $i ( 0 .. $result->ntuples - 1 ) { my ( $field1, $field2 ) = ($result->getvalue($i, 0), $result->getvalue($i, 1)); .... } } --Gene