--- trunk/index_DBI.pm 2003/02/16 22:41:37 13 +++ trunk/index_DBI.pm 2003/02/22 23:47:15 19 @@ -31,15 +31,18 @@ my $field = shift; +#print "#### delete_and_create($field)\n"; + $self->{dbh}->commit; - $self->{dbh}->begin_work; my $sql = "select count(*) from $field"; my $sth = $self->{dbh}->prepare($sql) || die $self->{dbh}->errstr(); # FIX: this is not a good way to check if table exists! - if (1 || $sth->execute() && $sth->fetchrow_hashref) { + if ($sth->execute() && $sth->fetchrow_hashref) { my $sql = "drop table $field"; -# my $sth = $self->{dbh}->do($sql) || die "SQL: $sql ".$self->{dbh}->errstr(); + $self->{dbh}->begin_work; + my $sth = $self->{dbh}->do($sql) || die "SQL: $sql ".$self->{dbh}->errstr(); + $self->{dbh}->commit; } $sql = "create table $field ( item varchar(255), @@ -48,10 +51,11 @@ ord int, primary key (item,ident) )"; -# $sth = $self->{dbh}->do($sql) || die "SQL: $sql ".$self->{dbh}->errstr(); - $sth = $self->{dbh}->do($sql) || warn "SQL: $sql ".$self->{dbh}->errstr(); + $self->{dbh}->begin_work; + $sth = $self->{dbh}->do($sql); # || warn "SQL: $sql ".$self->{dbh}->errstr(); $self->{dbh}->commit; + $self->{dbh}->begin_work; } @@ -59,8 +63,8 @@ my $self = shift; my $field = shift; - my $index_data = shift || return; - my $ident = shift || return; # e.g. library id + my $index_data = shift || print STDERR "\$index->insert($field,NULL,...)"; + my $ident = shift || ''; # e.g. library id if (! $index_data) { print STDERR "\$index->insert() -- no value to insert\n";