zby has asked for the wisdom of the Perl Monks concerning the following question:
with following code:DBD::ODBC::st execute failed: [IBM][Client Access Express ODBC Driver +(32-bit)][DB2/400 SQL]Data truncated. (SQL-01004)(DBD: st_execute/SQL +Execute err=-1) at a.pl line 33.
Setting the 'Longxxxxx' parameters did not help anything (anyway this is INSERT so this should not apply here). The debugging output:use Data::Dumper; use DBI; use strict; my $dbh = DBI->connect('dbi:ODBC:MID', 'midadmin', '*******') or die " +Nie moge sie polaczyc: $!" ; =pod $dbh->{LongTruncOk} = 1; $dbh->{LongReadLen} = 1024; DBI->trace(5); =cut my @kolumny = qw( MIDDELETIONFLAG UMREN MEINH UMREZ LAENG BREIT NOEHE VOLUM VOLEH BRGEW +GEWEI MESUB SYSTEM_ID LEGACY_ID MAKT_MAKTX_PL MAS_IADSC DUP_CHK MAS_I +APACS MARM_MEINS MAS_IANPAL ); my @vals = ("S", "1", "PAL", "1152", "", "", "00337", "1200", "800", " +972", "MM", "933120", "CM3", "313", "KG", "CS", "PLNCPL", "00337", "P +LNCPL", "00337PAL", ); my $cols = join ', ', 'MIDID', @kolumny; my $placeh = join ', ', map {'?'} 'MIDID', @kolumny; my $statement = "INSERT into middbexp.marmtest ($cols) values ($placeh +)"; print $statement, "\n"; my $sth = $dbh->prepare($statement); print "\n\n"; $sth->bind_param(1, 2, 4); for my $nrcol (1 .. $#kolumny + 1){ print "$nrcol, $kolumny[$nrcol - 1], $vals[$nrcol - 1]\n"; $sth->bind_param($nrcol + 1, $vals[$nrcol]); } my $rv = $sth->execute(); print "$rv\n";
INSERT into middbexp.marmtest (MIDID, MIDDELETIONFLAG, UMREN, MEINH, U +MREZ, LAENG, BREIT, NOEHE, VOLUM, VOLEH, BRGEW, GEWEI, MESUB, SYSTEM_ +ID, LEGACY_ID, MAKT_MAKTX_PL, MAS_IADSC, DUP_CHK, MAS_IAPACS, MARM_ME +INS, MAS_IANPAL) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, + ?, ?, ?, ?, ?, ?) 1, MIDDELETIONFLAG, S 2, UMREN, 1 3, MEINH, PAL 4, UMREZ, 1152 5, LAENG, 6, BREIT, 7, NOEHE, 00337 8, VOLUM, 1200 9, VOLEH, 800 10, BRGEW, 972 11, GEWEI, MM 12, MESUB, 933120 13, SYSTEM_ID, CM3 14, LEGACY_ID, 313 15, MAKT_MAKTX_PL, KG 16, MAS_IADSC, CS 17, DUP_CHK, PLNCPL 18, MAS_IAPACS, 00337 19, MARM_MEINS, PLNCPL 20, MAS_IANPAL, 00337PAL
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 'Data truncated' error when INSERTING (DBI)
by ScooterQ (Pilgrim) on Jul 16, 2003 at 19:49 UTC | |
by zby (Vicar) on Jul 17, 2003 at 08:18 UTC | |
|
Re: 'Data truncated' error when INSERTING (DBI)
by cfreak (Chaplain) on Jul 16, 2003 at 19:50 UTC | |
|
Re: 'Data truncated' error when INSERTING (DBI)
by sgifford (Prior) on Jul 16, 2003 at 20:19 UTC |