pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedDereferencing PG_Result
2+ messages / 2 participants
[nested] [flat]
* Dereferencing PG_Result
@ 1998-11-23 15:52 david@tte.tamu.edu
1998-11-23 23:08 ` Re: [INTERFACES] Dereferencing PG_Result Gene Selkov Jr. <selkovjr@mcs.anl.gov>
0 siblings, 1 reply; 2+ messages in thread
From: david@tte.tamu.edu @ 1998-11-23 15:52 UTC (permalink / raw)
To: pgsql-interfaces
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?
David Sweeney
david@tte.tamu.edu
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [INTERFACES] Dereferencing PG_Result
1998-11-23 15:52 Dereferencing PG_Result david@tte.tamu.edu
@ 1998-11-23 23:08 ` Gene Selkov Jr. <selkovjr@mcs.anl.gov>
0 siblings, 0 replies; 2+ messages in thread
From: Gene Selkov Jr. @ 1998-11-23 23:08 UTC (permalink / raw)
To: david@tte.tamu.edu; pgsql-interfaces
> 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1998-11-23 23:08 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-11-23 15:52 Dereferencing PG_Result david@tte.tamu.edu
1998-11-23 23:08 ` Gene Selkov Jr. <selkovjr@mcs.anl.gov>
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