I've got some perl code I wrote as follows that has two parts which are
basically the same logic, but one looks one way in a key sequence, using min,
the other goes the other way, using max, as follows:

 if      ( $increment > 0 )
        {
            $d_query_string = "select min(acct_no), $fieldlist from customer "
                            . " where branch_id=\'$branch_id\' "
                            . " and acct_no>\'$acct_no\' ";
            $relword = "after";
        }
        elsif   ( $increment < 0 )
        {
            $d_query_string = "select max(acct_no), $fieldlist from customer "
                            . " where branch_id=\'$branch_id\' "
                            . " and acct_no < \'$acct_no\' ";
            $relword = "before";
        }

branch_id is char(3), and acct_no is char(10) and are the only two members of
the primary key, mentioned in the order I give here.  The intention here (which
by the way may be done better with another method, and if so I'd like to know
it, but the failure I think is still important, and I should mention, I haven't
tried this on 3.22, only 3.21) is to pick the next (if increment is 1) or 
preceding (if $increment is -1) acct_no row in the sequence.  Plainly stated,
I can get the next one, but not the preceding, with the above code (which is
perl, oh yes I said that).  I think when I tried the code for the preceding
I got some minimum key in the table for the given branch_id.  So, for example
with $increment 1, present acct_no at 20000, and the nearest next acct_no 20005,
I get the row with that acct_no 20005.  When the $increment is -1, and the
nearest preceding is 19009, and the smallest key value is 10000, I get the row
with key value 10000.  Unless I'm crazy this is at least a logical inconsistency
although I'd be reasonably credulous if someone claimed it complied with SQL
standards somehow.  If this is a bug, can it be (has it been) fixed (please?)?

Anyhow, yours stressfully, Xeno Campanoli
-----------------------------------------------------------
Send a mail to [EMAIL PROTECTED] with
unsubscribe mysql [EMAIL PROTECTED]
in the body of the message to unsubscribe from this list.

Reply via email to