Re: from pgsql_perl5 to DBD-Pg
- From: "Bob" <catdogbeloved@xxxxxxxxx>
- Date: 28 Feb 2007 00:22:03 -0800
UPDATE
#
# How to port code from Pg [1] to DBI [2]
# =======================================
#
# Tested and working thus far:
# ----------------------------
#
# [1]: $dbh = Pg::connectdb("dbname=$dbname");
# [2]: $dbh = DBI->connect("DBI:Pg:dbname=$dbname", "", "",
{AutoCommit => 1});
#
# [1]: $dbh->exec("<SQL STATEMENT>");
# [2]: $dbh->do("<SQL STATEMENT>"); # non select
# [2]: $sth = $dbg->prepare("<SQL STATEMENT>"); $sth->execute; #
select
#
# [1]: $dbh->status == 0
# [2]: (not defined $dbh->errstr)
#
# Returns the number of records in the query result:
# [1]: $sth->ntuples
# [2]: $sth->rows
# [2]: @$sth
#
# Returns the number of fields in the query result:
# [1]: $sth->nfields
# [2]: $sth->{NUM_OF_FIELDS}
#
# Returns the field name associated with the given field number:
# [1] $sth->fname($i)
# [2]: $sth->{NAME}->[$i]
#
# Returns the value of the given record and field number:
# [1]: $value = $sth->getvalue($r,$f);
# [2]: $results = $sth->fetchall_arrayref(); $value = $results->[$r]
[$f];
#
# Pending solution thus far:
# --------------------------
#
# 1. There are two possible methods to return the number of records
# in the query result. The method @$sth works where $sth->rows
fails,
# in the same code structure, but the reason is not clear.
#
# 2. Print all the records in an intelligent manner:
# [1]: $sth->print($fout, $header, $align, $standard, $html3,
$expanded, $pager,
$fieldSep, $tableOpt, $caption)
# [2]: open thread at http://groups.google.it/group/perl.dbi.users/browse_thread
/thread/3fa50f7b647ada6d?hl=en
#
.
- References:
- from pgsql_perl5 to DBD-Pg
- From: Bob
- from pgsql_perl5 to DBD-Pg
- Prev by Date: Re: (Fwd) DBI's method for reading [row x,field y]
- Next by Date: Re: (Fwd) DBI's method for reading [row x,field y]
- Previous by thread: Re: from pgsql_perl5 to DBD-Pg
- Next by thread: Re: from pgsql_perl5 to DBD-Pg
- Index(es):
Relevant Pages
|