Dereferencing PG_Result
Dereferencing PG_Result
От:
david@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?
David Sweeney
david@tte.tamu.edu
Re: [INTERFACES] Dereferencing PG_Result
От:
"Gene Selkov Jr." <selkovjr@mcs.anl.gov>
Дата:
> 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