pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gene Selkov Jr. <selkovjr@mcs.anl.gov>
To: david@tte.tamu.edu
To: pgsql-interfaces@postgresql.org
Subject: Re: [INTERFACES] Dereferencing PG_Result
Date: Mon, 23 Nov 1998 18:08:23 -0500
Message-ID: <199811232306.RAA23573@antares.mcs.anl.gov> (raw)
In-Reply-To: <Pine.LNX.3.96.981123094628.21949C-100000@tte.tamu.edu>

> 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



view thread (2+ messages)

Message-ID: <199811232306.RAA23573@antares.mcs.anl.gov>
Permalink:  ../199811232306.RAA23573@antares.mcs.anl.gov/
Also on:    postgresql.org/message-id/199811232306.RAA23573@antares.mcs.anl.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: selkovjr@mcs.anl.gov, david@tte.tamu.edu
  Subject: Re: [INTERFACES] Dereferencing PG_Result
  In-Reply-To: <199811232306.RAA23573@antares.mcs.anl.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox