SQL_BIT is defined, when I ran:

use DBI qw(:sql_types); use Data::Dumper; #use strict; use warnings; foreach (sort @{$DBI::EXPORT_TAGS{sql_types}}) { printf "%s=%d\n", $_, &{"DBI::$_"}; }

One of the output line says:

SQL_BIT=-7

So there was some hope... However the following code compiled okay, but still gave the same error (data too long):

use DBI qw(:sql_types); use Data::Dumper; use strict; use warnings; my $dsn = "DBI:mysql:database=test;host=foo"; my $dbh = DBI->connect($dsn, 'root', 'root', {RaiseError => 1}); my $insert = "insert into test(a) value(?)"; my $select = "select * from test"; my $insert_st = $dbh->prepare($insert); my $select_st = $dbh->prepare($select); $insert_st->bind_param(1, 3, SQL_BIT); $insert_st->execute() or die $dbh->errstr; $select_st->execute(); my $ref = $select_st->fetchall_arrayref(); print Dumper($ref);

This further proves to me that, just like Zaxo and I diiscussed in private, this is a bug, integer was not trimed to fit.

By the way, I tested Zaxo's chr(3) bit, and that worked.

Or we can put it in virtualsue's way, the DBD has not yet updated for MySQL 5. By the way, MySQL only started to support BIT data type in version 5.


In reply to Re^2: Handle MySQL BIT data type in Perl by pg
in thread Handle MySQL BIT data type in Perl by pg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.