insert into test(a) value(3) #### use DBI; 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(3)"; my $select = "select * from test"; my $insert_st = $dbh->prepare($insert); my $select_st = $dbh->prepare($select); $insert_st->execute() or die $dbh->errstr; $select_st->execute(); my $ref = $select_st->fetchall_arrayref(); print Dumper($ref); #### use DBI; 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->execute(3) or die $dbh->errstr; $select_st->execute(); my $ref = $select_st->fetchall_arrayref(); print Dumper($ref); #### DBD::mysql::st execute failed: Data too long for column 'a' at row 1 at math1.pl line 11. DBD::mysql::st execute failed: Data too long for column 'a' at row 1 at math1.pl line 11. #### use DBI; 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->execute(pack('b3', '110')) or die $dbh->errstr; $select_st->execute(); my $ref = $select_st->fetchall_arrayref(); print Dumper($ref);