documentation bugs on LongRealLen
From: Bart Lateur (bart.lateur_at_pandora.be)
Date: 12/10/04
- Previous message: Ronald J Kimball: "RE: Nested query problem"
- Next in thread: Michael Peppler: "Re: documentation bugs on LongRealLen"
- Reply: Michael Peppler: "Re: documentation bugs on LongRealLen"
- Reply: Tim Bunce: "Re: documentation bugs on LongRealLen"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: dbi-users@perl.org Date: Fri, 10 Dec 2004 01:48:26 +0100
There's a few bugs in the code of the section of LongReadLen, even in
the latest version of DBI that is on CPAN. I quote:
If you can't be sure what value to use you could execute an
extra select statement to determine the longest value. For
example:
$dbh->{LongReadLen} = $dbh->selectrow_array{qq{
SELECT MAX(long_column_name) FROM table WHERE ...
});
$sth = $dbh->prepare(qq{
SELECT long_column_name, ... FROM table WHERE ...
});
Bug 1is a typo:
- $dbh->{LongReadLen} = $dbh->selectrow_array{qq{
+ $dbh->{LongReadLen} = $dbh->selectrow_array(qq{
Bug 2 is thinko. If your rows contain the values "alpha", "beta", "zeta"
"omega" in that column, $dbh->{LongReadLen} will be set to "zeta". I
don't think that will buy us anything good. You want the *length* of the
*longest* string, not the string that sorts last in the word list. So,
somebody forgot about length(), or whatever the proper keyword is in
SQL.
Unfortunately that keyword is highly unportable. A Google search showed
me that octet_length() is probably what I'm after, for SQL-92. I tried
it on MS-Access using DBD::ODBC, and it failed completely. I replaced it
with the VB keyword "Len", and it worked... more or less.
One word of caution, with regards to MS-Access. It turned out that
Len(), when used in Ms-Access' SQL, is actually treated as a string, so
MAX() returned the wrong result. The max value I got was about 82000,
while the actual longest string was closer to 180000 bytes. What caused
it is simply that "8" gt "1".
Using a numerical context for that function, by adding 0 for example,
might have helped. I haven't tried it. It was a one shot program anyway.
-- Bart.
- Previous message: Ronald J Kimball: "RE: Nested query problem"
- Next in thread: Michael Peppler: "Re: documentation bugs on LongRealLen"
- Reply: Michael Peppler: "Re: documentation bugs on LongRealLen"
- Reply: Tim Bunce: "Re: documentation bugs on LongRealLen"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|