documentation bugs on LongRealLen

From: Bart Lateur (bart.lateur_at_pandora.be)
Date: 12/10/04

  • Next message: Michael Peppler: "Re: documentation bugs on LongRealLen"
    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.
    

  • Next message: Michael Peppler: "Re: documentation bugs on LongRealLen"

    Relevant Pages

    • Re: Using the same subroutine to read files with different structures
      ... to read each line from the external file into a temporary string, ... However, to write a really good parser relying mostly on internal read, there typically isn't enough error reporting granularity in the IOSTAT return codes to do a really proper job of it, not to mention that the IOSTAT values aren't portable. ... returns an array of keyword strings ...
      (comp.lang.fortran)
    • Re: Crazy Testing ideas
      ... > interesting bugs? ... Something on the lines of Shoe testing as James Bach ... Each test has some cost and and some value. ... string, then copying it ten times; then copy the new string ten times; ...
      (comp.software.testing)
    • Re: converting dict to object
      ... doesn't work [3 is not a string]; ... Python identifier (not a keyword). ... bitten by the keyword problem. ...
      (comp.lang.python)
    • Re: Using the same subroutine to read files with different structures
      ... to read each line from the external file into a temporary string, ... However, to write a really good parser relying mostly on internal read, there typically isn't enough error reporting granularity in the IOSTAT return codes to do a really proper job of it, not to mention that the IOSTAT values aren't portable. ... returns an array of keyword strings ... the inputs under differing namelists then you will find the restriction. ...
      (comp.lang.fortran)
    • Re: Using the same subroutine to read files with different structures
      ... to read each line from the external file into a temporary string, ... However, to write a really good parser relying mostly on internal read, there typically isn't enough error reporting granularity in the IOSTAT return codes to do a really proper job of it, not to mention that the IOSTAT values aren't portable. ... returns an array of keyword strings ... the inputs under differing namelists then you will find the restriction. ...
      (comp.lang.fortran)