<?xml version="1.0" encoding="windows-1252"?>
<node id="358660" title="zby's scratchpad" created="2004-06-01 18:07:08" updated="2005-08-11 03:54:19">
<type id="182711">
scratchpad</type>
<author id="228394">
zby</author>
<data>
<field name="doctext">
&lt;code&gt;
use Data::Dumper;
use DBI;
use strict;

my $dbh = DBI-&gt;connect('dbi:ODBC:MID', 'midadmin', '*****') or die "Nie moge sie polaczyc: $!" ;
=pod
$dbh-&gt;{LongTruncOk} = 1;
$dbh-&gt;{LongReadLen} = 1024;
DBI-&gt;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_IAPACS MARM_MEINS MAS_IANPAL
);


my @vals = ("S", "1", "PAL", "1152", "", "", "00337", "1200", "800", "972", "MM", "933120", "CM3", "313", "KG", "CS", "PLNCPL", "00337", "PLNCPL", "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-&gt;prepare($statement);

print "\n\n";
$sth-&gt;bind_param(1, 2, 4);
for my $nrcol (1 .. $#kolumny + 1){
    print "$nrcol, $kolumny[$nrcol - 1], $vals[$nrcol - 1]\n";
    $sth-&gt;bind_param($nrcol + 1, $vals[$nrcol]);
}
my $rv = $sth-&gt;execute();
print "$rv\n";

&lt;/code&gt;        


The output:
&lt;code&gt;
DBD::ODBC::st execute failed: [IBM][Client Access Express ODBC Driver (32-bit)][DB2/400 SQL]Data truncated. (SQL-01004)(DBD: st_execute/SQLExecute err=-1) at a.pl line 33.
INSERT into middbexp.marmtest (MIDID, MIDDELETIONFLAG, UMREN, MEINH, UMREZ, LAENG, BREIT, NOEHE, VOLUM, VOLEH, BRGEW, GEWEI, MESUB, SYSTEM_ID, LEGACY_ID, MAKT_MAKTX_PL, MAS_IADSC, DUP_CHK, MAS_IAPACS, MARM_MEINS, 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


&lt;/code&gt;
&lt;br /&gt;&lt;a HREF="/index.pl?node_id=280268"&gt;Autogenerate Test Scripts&lt;/a&gt;</field>
</data>
</node>
