in reply to Bug in DBI? (Surely Not??)


Kudos to Cybear!!! Many +++++++'s

If I put a sprintf to the number fields, they come out
correct. Bit messy, but works.

Strange thing is, I was updating a database table using
the contents of selectall_arrayref, and the code
doesnt work correctly, UNLESS I do a sprintf on the
numeric items in the array.... Bit naff.....

But It works!!! 2 days are over!!! Im Free!!!1

Kevman

Replies are listed 'Best First'.
Re: Re: Bug in DBI? (Surely Not??)
by mpeppler (Vicar) on Jun 14, 2002 at 20:03 UTC
    A couple of comments.

    First, the table is defined as a "float", and with Sybase that means IEEE float if the platform supports it. As such it's an imprecise data type (and one that I would NOT use for money amounts!). You will almost by definition get data that is different from what you insert.
    For example, I created a dummy table with a single float column, and inserted your 999999999999.0012 value. Running a select on that value with sqsh gives me 999999999999.001221.

    Second - when you fetch a float value DBD::Sybase will store that internally as a perl "numeric" value (an NV). There shouldn't be any loss of precision there, but it's a float, so, as stated above, there are no guarantees.

    For handling precise amounts (financial transactions, etc) I would strongly recommend using either the Sybase MONEY datatype (which is an 8 byte value with an implied 4 decimal places) or using a NUMERIC datatype.

    Michael

Re: Re: Bug in DBI? (Surely Not??)
by dda (Friar) on Jun 14, 2002 at 15:44 UTC
    >Im Free!!!

    So, you are gone and we will not see the code? :)

    --dda