Re: DBI doc curiosity



On 2007-08-20 16:21:47 +1000, Ron Savage wrote:
Under the write-up for fetchall_hashref is some sample code:
$dbh->{FetchHashKeyName} = 'NAME_lc';
$sth = $dbh->prepare("SELECT FOO, BAR, ID, NAME, BAZ FROM TABLE");
$sth->execute;
$hash_ref = $sth->fetchall_hashref('id');
print "Name for id 42 is $hash_ref->{42}->{name}\n";

However, after a call to $dbh -> primary_key_info(...), it seems the only
acceptable values for the parameter in the call to fetchall_hashref() are
TABLE_CAT, TABLE_SCHEM, TABLE_NAME, and KEY_SEQ. Is that right?

The example assumes that there is a table called "TABLE" with at least
the fields FOO, BAR, ID, NAME, and BAZ. If you don't have such a table
(and at least Oracle thinks "TABLE" is an invalid table name), it won't
work of course. You are supposed to replace the table name and field
names with the name and fields of a table which actually exists.

I don't understand how primary_key_info() gets into the picture. Do you
mean column_info?

hp


--
_ | Peter J. Holzer | If I wanted to be "academically correct",
|_|_) | Sysadmin WSR | I'd be programming in Java.
| | | hjp@xxxxxxxxx | I don't, and I'm not.
__/ | http://www.hjp.at/ | -- Jesse Erlbaum on dbi-users

Attachment: pgpe2jggXqFLK.pgp
Description: PGP signature



Relevant Pages

  • Has working with raster graphics always been this complicated?
    ... I'm not new to programming, but I'm new to Java, at least as far as ... I find references to Image objects, Graphics ... picture graphics to be revealed, in the form of GIF files. ...
    (comp.lang.java.help)
  • Re: Connecting to Progress Database
    ... AFAIK Progress and Postgress are two quite different databases ... ...
    (perl.dbi.users)
  • Re: Connecting to Progress Database
    ... AFAIK Progress and Postgress are two quite different databases ... ...
    (perl.dbi.users)
  • Re: DBI-Bind parameters
    ... Please don't post pseudo code. ...
    (perl.dbi.users)
  • Use Jesus Christ
    ... > programming until very recently. ... >, but I've occasionally tried to understand Smalltalk ... In Java I've mostly been limited to server-side ... Object oriented design is a mental picture of objects and messages. ...
    (comp.object)