One correction to my last mail:
The "OK 1" is NOT OK! I do not know what happend. Likely I had a look at the
wrong file while checking the results. So I can not blame Sun for the strange
things ;-)
Another observation: While comparing the trace-output from the Linux-tests I
discovered that there is a difference in executing the UPDATE-statement (3 times):
OK:
-> execute in DBD::File::st for DBD::CSV::st
(DBI::st=HASH(0x860b3b4)~0x8607948 '20040101' '20080630' 'ID001') thr#8167008
-> execute in DBD::File::st for DBD::CSV::st
(DBI::st=HASH(0x860b3b4)~0x8607948 '20050701' '20100430' 'ID003') thr#8167008
-> execute for DBD::CSV::st (DBI::st=HASH(0x860b3b4)~0x8607948 '20050301'
'20091231' 'ID002') thr#8167008
NOT OK:
-> execute in DBD::File::st for DBD::CSV::st
(DBI::st=HASH(0x18e7698)~0x18e75c0 '20040101' '20080630' 'ID001') thr#1880010
-> execute for DBD::CSV::st (DBI::st=HASH(0x18e7698)~0x18e75c0 '20050701'
'20100430' 'ID003') thr#1880010
-> execute for DBD::CSV::st (DBI::st=HASH(0x18e7698)~0x18e75c0 '20050301'
'20091231' 'ID002') thr#1880010
But may be this is only a matter of reporting...
Greetings
Robert
----
Robert Roggenbuck schrieb:
Hi all,
unfortunately I must continue this thread. I managed to update DBI on
the Web-Server, where my test-script corrupts data while updating - and
still it does not work. I checked it on another computer where it works
fine:
OK 1:
DBI 1.607-ithread
DBD::CSV version 0.22
perl 5.10.0
Linux 2.6.27.15-170.2.24.fc10.x86_64 #1 SMP Wed Feb 11 23:14:31 EST 2009
x86_64 x86_64 x86_64 GNU/Linux
OK 2:
DBI 1.52-ithread
DBD::CSV version 0.22
perl 5.8.8
Linux 2.6.18.8-0.7-default #1 SMP Tue Oct 2 17:21:08 UTC 2007 i686 i686
i386 GNU/Linux
NOT OK:
DBI 1.607-ithread
DBD::CSV version 0.22
perl 5.8.8
SunOS 5.10 Generic_118822-30 sun4u sparc SUNW,Ultra-250
Now it seems to me that the difference is the OS or a speciallity in a
strange setup of Perl which I can not see. Even trace(15) shows no
differences in the execute-part (trace(9), as I set in the script, is
for the execute-part the same as 15).
What's going on? Where should I look for the cause of the problem?
Greetings
Robert
PS: Here again my test-script. The 1st execution creates the table
'Projects' in /tmp. The 2nd execution should update the data (infact if
everything went fine nothing changes, because the UPDATE woks with the
same data as the INSERT).
###########
use strict;
use warnings;
use DBI;
my %projects = (
'ID001' => {
'begin' => '20040101',
'end' => '20080630',
},
'ID002' => {
'begin' => '20050301',
'end' => '20091231',
},
'ID003' => {
'begin' => '20050701',
'end' => '20100430',
},
);
DBI->trace(9);
my $dbh = DBI->connect("dbi:CSV:f_dir=/tmp;csv_eol=\n",'','',
{ AutoCommit => 1, RaiseError => 1 });
my $sql = "CREATE TABLE Projects (
project_id VARCHAR(32) PRIMARY KEY,
begin CHAR(8) NOT NULL,
end CHAR(8) NOT NULL
)";
$dbh->do($sql) unless -e '/tmp/Projects';
warn "will fill/actualise table 'Projects'\n";
my $sql_up = "UPDATE Projects SET begin=?, end=? WHERE project_id LIKE ?";
my $sth_up = $dbh->prepare($sql_up);
my $sql_in = "INSERT INTO Projects (project_id, begin, end) VALUES (?,
?, ?)";
my $sth_in = $dbh->prepare($sql_in);
foreach my $id (keys %projects) {
my $begin = $projects{$id}->{begin};
my $end = $projects{$id}->{end};
warn "will try UPDATE Projects\n";
my $result = $sth_up->execute($begin, $end, $id);
if ($result == 0) {
warn "will INSERT INTO Projects\n";
$result = $sth_in->execute($id, $begin, $end);
if ($result == 0) {
warn "Could not update table 'Projects' project $id\n";
}
}
}
$sth_up->finish();
$sth_in->finish();
$dbh->disconnect();
warn "finished\n";
###########