Re: bug in SQLBindCol

Paul DuBois <[email protected]>
Newsgroups gmane.comp.db.mysql.perl
Message-ID <p06230968c053248f746e@[192.168.0.35]>
At 17:52 +0100 3/31/06, Martin J. Evans wrote:
>I appologise in advance for not looking into this any further but 
>I'm very time
>poor at the moment (if you are on the dbi-users list you'll know why).
>
>create table test(a numeric(10.6))
>insert into test (1000)
>SQLBindCol(SQL_C_CHAR, buffer length 11)
>   11 is OK as its 4.6 = 11 chrs and bound columns are not null terminated
>SQLFetch
>
>you get back "1000.00000" and a length of 11 instead of
>"1000.000000" and a length of 11.
>
>This is most noticeable under DBD::OBDC as the 11 is use to create a perl
>scalar and so you get whatever trailing garbage is in the 11th chr. i.e. you
>often end up with 1000.00000\u0000.
>
>I got around the problem by changing my code to numeric(11.6) and ensuring no
>value above 9999 can be entered.
>
>Also, this raised another issue with numeric(10.6) in mysql itself.
>If you insert 10000 into a 10.6 it goes in without error but when you read it
>back it is 9999.999999.

10.6 allows 4 digits to the left of the decimal point. 10000 has 5 digits.
MySQL no longer stores 10000, it clips it.  This is mentioned at:

http://dev.mysql.com/doc/refman/5.0/en/upgrading-from-4-1.html

See the "Server Changes" section of that page.

-- 
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.