[prev in list] [next in list] [prev in thread] [next in thread]
List: dbi-dev
Subject: Re: How select from table using DBD::Pg
From: Edmund Mergl <E.Mergl () bawue ! de>
Date: 1997-11-28 23:11:42
[Download RAW message or body]
*** From dbi-users -- To unsubscribe, see the end of this message. ***
Tim Bunce wrote:
>
> *** From dbi-dev -- To unsubscribe, see the end of this message. ***
>
> > From: Dan Lauterbach <danla@dimensional.com>
> >
> > Help!
> >
> > I am attempting to use DBD::Pg to select from a table in Postgres. I
> > have unsuccessfully tried many different approaches:
> >
> > Approach 1: Prepared with placeholders using "bind_param" method to pass
> > bind value.
> > $sth = $dbh->prepare("SELECT * from masterpr where docno = ?");
> > $sth->bind_param(1, $_) || die $sth->errstr;
> >
> > Can't bind unknown placeholder ':p1' at ./select.pl line 26, <MMCA>
>
> > Approach 2: Prepared with placeholder using "execute" method to pass
> > bind value.
> > $sth = $dbh->prepare("SELECT * from masterpr where docno = ?");
> > $sth->execute($_);
> >
> > execute called with 1 bind variables, 0 needed at ./select.pl line 30,
> > <MMCA> chunk 3348.
> > NOTICE:UserAbortTransactionBlock and not in in-progress state
> >
> > It appears as though DBD::Pg just doesn't accept placeholders.
>
> I'd agree with you.
>
> > $record = $sth->fetch;
> >
> > This approach didn't error out, but instead printed "$record" out as
> > follows:
> >
> > ARRAY(0x813d990)
>
> Which you'd expect if you'd read the docs. Try fetchrow_array instead.
>
> > Approach 4: Prepare and execute each time. Bind columns to perl
> > variables.
>
> > $sth = $dbh->prepare("SELECT * from masterpr where docno = \'$_\'");
> > $sth->bind_columns(undef, $Docno,$Rev,$Desc,$Effdate,$Obsdate,$Pdf);
> >
> > bind_columns called with 6 refs when 0 needed. at ./select.pl line 36,
>
> Looks like DBD::pg doesn't do-the-right-thing here, specifically it
> doesn't set DBIc_NUM_FIELDS internally.
>
> Talk to the author.
>
> > I am new to this DBMS stuff and would really appreciate it somebody
> > could show me what I'm doing wrong.
>
> Nothing.
>
> Tim.
>
A simple bind-columns works as shown in the test script.
Placeholders are not supported.
Edmund
--
+-------------------+---------------------+
| Edmund Mergl | E.Mergl@bawue.de |
| Im Haldenhau 9 | fon: +49=711-747503 |
| D 70565 Stuttgart | |
|-------------------+---------------------|
| http://www.bawue.de/~mergl/ |
+-----------------------------------------+
------------------------------------------------------------------------------
To unsubscribe from this list, please visit http://www.fugue.com/dbi.
If you are without web access, or if you are having trouble with the web page,
please send mail to dbi-request@fugue.com. Please try to use the web
page first - it will take a long time for your request to be processed by hand.
------------------------------------------------------------------------------
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic