Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: DBI Placeholders and DB2 Integers

by Eliya (Vicar)
on Apr 12, 2012 at 01:49 UTC ( #964679=note: print w/ replies, xml ) Need Help??


in reply to Re: DBI Placeholders and DB2 Integers
in thread DBI Placeholders and DB2 Integers

As it looks, your numbers are Math::BigInt objects, which the DBD driver may not be handling properly.

Is there any specific reason for using bigints, or do you just have a use bigint; pragma somewhere in the program, which inadvertendly applies to a wider scope than necessary? (Note that the pragma is lexically scoped, so you can keep it restricted to the minimal scope required.)

Anyhow, assuming you do not need bigints for those values, you might want to try converting those Math::BigInt objects to normal numbers by using ->numify, e.g.

$doc_len->numify

Or better yet, find out why they've become bigints in the first place...


Comment on Re^2: DBI Placeholders and DB2 Integers
Select or Download Code
Re^3: DBI Placeholders and DB2 Integers
by acka.au (Novice) on Apr 12, 2012 at 03:01 UTC

    Well I am certainly not doing anything intentional to use BigInts.

    However I notice that the Math::Base36 module uses BigInts and I do use the Base36 module. In fact I use the Base36::decode_base36() function in the same part of code which is doing this DB2 update (I have to extract the integers from a Base36 encoded string).

    How do I limit the context of the BigInt? Alternatively, since I haven't used (or heard of) numify before, is that a standard fucntion in Perl v5.8.8 or do I need to pull in another module?

      However I notice that the Math::Base36 module uses BigInts...

      In this case, it's probably easiest to ->numify them, which is a method provided by the Math::BigInt module.  In other words, there's no need to load any other module.  Your numbers already are objects of type Math::BigInt, so you can simply say $doc_len->numify, etc.

      (Don't use ->as_int instead (as mentioned in the docs), because this method wouldn't remove the Math::BigInt type...)

        SUCCESS!

        What I have done is 'decode' the base 36 string into a string of regular base 10 numbers and then split this into its component parts. (Previously I was splitting the base 36 string and then decoding each component directly to a numeric variable).

        The result is that the numeric variables get initialised as regular integers and the DBI module is then happy to use them with the prepared place holders.

        Many thanks Eliya, et al, as this had been driving me nuts for about a day and a half. Guess I should have checked with The Monks earlier! :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://964679]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2014-09-19 17:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (143 votes), past polls