Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e2332bfd

Von Sven Schöling vor mehr als 8 Jahren hinzugefügt

  • ID e2332bfd203a5d9925034dfdd90a15b3c9c66044
  • Vorgänger 660c7e53
  • Nachfolger 70678a2e

DB Handling: Einige executes mit Fehlerbehandlung versehen

Unterschiede anzeigen:

SL/Controller/CsvImport.pm
use SL::DB::CsvImportReport;
use SL::DB::Unit;
use SL::DB::Helper::Paginated ();
use SL::DBUtils qw(do_statement);
use SL::Helper::Flash;
use SL::Locale::String;
use SL::SessionFile;
......
push @raw_methods, $self->raw_data_headers->{headers}->[$i];
}
$sth->execute($report->id, $_, 0, $headers[$_]) for 0 .. $#headers;
do_statement($::form, $sth, $query, $report->id, $_, 0, $headers[$_]) for 0 .. $#headers;
# col offsets
my $o1 = @info_methods;
......
$self->track_progress(progress => $row / @{ $self->data } * 100) if $row % 1000 == 0;
my $data_row = $self->{data}[$row];
$sth->execute($report->id, $_, $row + 1, $data_row->{info_data}{ $info_methods[$_] }) for 0 .. $#info_methods;
$sth->execute($report->id, $o1 + $_, $row + 1, $data_row->{object}->${ \ $methods[$_] }) for 0 .. $#methods;
$sth->execute($report->id, $o2 + $_, $row + 1, $data_row->{raw_data}{ $raw_methods[$_] }) for 0 .. $#raw_methods;
do_statement($::form, $sth, $query, $report->id, $_, $row + 1, $data_row->{info_data}{ $info_methods[$_] }) for 0 .. $#info_methods;
do_statement($::form, $sth, $query, $report->id, $o1 + $_, $row + 1, $data_row->{object}->${ \ $methods[$_] }) for 0 .. $#methods;
do_statement($::form, $sth, $query, $report->id, $o2 + $_, $row + 1, $data_row->{raw_data}{ $raw_methods[$_] }) for 0 .. $#raw_methods;
$sth2->execute($report->id, $row + 1, 'information', $_) for @{ $data_row->{information} || [] };
$sth2->execute($report->id, $row + 1, 'errors', $_) for @{ $data_row->{errors} || [] };
do_statement($::form, $sth2, $query2, $report->id, $row + 1, 'information', $_) for @{ $data_row->{information} || [] };
do_statement($::form, $sth2, $query2, $report->id, $row + 1, 'errors', $_) for @{ $data_row->{errors} || [] };
}
1;
}) or do { die SL::DB->client->error };
......
for my $i (0 .. $#{ $self->worker->profile }) {
my $row_ident = $self->worker->profile->[$i]->{row_ident};
$sth->execute($report->id, $_, $i, $headers->{$row_ident}->[$_]) for 0 .. $#{ $headers->{$row_ident} };
do_statement($::form, $sth, $query, $report->id, $_, $i, $headers->{$row_ident}->[$_]) for 0 .. $#{ $headers->{$row_ident} };
}
# col offsets
......
my $o1 = $off1->{$row_ident};
my $o2 = $off2->{$row_ident};
$sth->execute($report->id, $_, $row + $n_header_rows, $data_row->{info_data}{ $info_methods->{$row_ident}->[$_] }) for 0 .. $#{ $info_methods->{$row_ident} };
$sth->execute($report->id, $o1 + $_, $row + $n_header_rows, $data_row->{object}->${ \ $methods->{$row_ident}->[$_] }) for 0 .. $#{ $methods->{$row_ident} };
$sth->execute($report->id, $o2 + $_, $row + $n_header_rows, $data_row->{raw_data}{ $raw_methods->{$row_ident}->[$_] }) for 0 .. $#{ $raw_methods->{$row_ident} };
do_statement($::form, $sth, $query, $report->id, $_, $row + $n_header_rows, $data_row->{info_data}{ $info_methods->{$row_ident}->[$_] }) for 0 .. $#{ $info_methods->{$row_ident} };
do_statement($::form, $sth, $query, $report->id, $o1 + $_, $row + $n_header_rows, $data_row->{object}->${ \ $methods->{$row_ident}->[$_] }) for 0 .. $#{ $methods->{$row_ident} };
do_statement($::form, $sth, $query, $report->id, $o2 + $_, $row + $n_header_rows, $data_row->{raw_data}{ $raw_methods->{$row_ident}->[$_] }) for 0 .. $#{ $raw_methods->{$row_ident} };
$sth2->execute($report->id, $row + $n_header_rows, 'information', $_) for @{ $data_row->{information} || [] };
$sth2->execute($report->id, $row + $n_header_rows, 'errors', $_) for @{ $data_row->{errors} || [] };
do_statement($::form, $sth2, $query2, $report->id, $row + $n_header_rows, 'information', $_) for @{ $data_row->{information} || [] };
do_statement($::form, $sth2, $query2, $report->id, $row + $n_header_rows, 'errors', $_) for @{ $data_row->{errors} || [] };
}
1;
}) or do { die SL::DB->client->error };
SL/DB/Helper/ActsAsList.pm
get_previous_in_list get_next_in_list get_full_list);
use Carp;
use SL::X;
my %list_spec;
......
my $sth = $self->db->dbh->prepare($query) || die $self->db->dbh->errstr;
foreach my $new_position (1 .. scalar(@ids)) {
$sth->execute($new_position, $ids[$new_position - 1]) || die $sth->errstr;
$sth->execute($new_position, $ids[$new_position - 1]) || die SL::X::DBUtilsError->new(error => $sth->errstr);
}
$sth->finish;
SL/GoBD.pm
my $query = "SELECT " . join(', ', @select_tokens) . " FROM $table $where_clause";
my $sth = $::form->get_standard_dbh->prepare($query);
$sth->execute(@values) or die "error executing query $query: " . $sth->errstr;
$sth->execute(@values) or $::form->dberror($query);
while (my $row = $sth->fetch) {
for my $keep_col (@{ $known_tables{$table}{keep} || [] }) {
SL/IC.pm
p.id IN ($in)
SQL
my $sth_tax = prepare_query($::form, $dbh, <<SQL);
my $query_tax = <<SQL;
SELECT c.accno, t.taxdescription AS description, t.rate, t.taxnumber
FROM tax t
LEFT JOIN chart c ON c.id = t.chart_id
......
WHERE tk.chart_id = ? AND startdate <= ?
ORDER BY startdate DESC LIMIT 1)
SQL
my $sth_tax = prepare_query($::form, $dbh, $query_tax);
while (my ($index => $part_id) = each %args) {
my $ref = $accno_by_part{$part_id} or next;
......
$form->{"${_}_accno_$index"} = $accounts{"${_}_accno"} for qw(inventory income expense);
$sth_tax->execute($accounts{$inc_exp}, quote_db_date($transdate));
$sth_tax->execute($accounts{$inc_exp}, quote_db_date($transdate)) || $::form->dberror($query_tax);
$ref = $sth_tax->fetchrow_hashref or next;
$form->{"taxaccounts_$index"} = $ref->{"accno"};
SL/SEPA.pm
$transfer->{reference} = "${invnumber}-${num_payments}";
}
$h_item_id->execute();
$h_item_id->execute() || $::form->dberror($q_item_id);
my ($item_id) = $h_item_id->fetchrow_array();
my $end_to_end_id = strftime "LXO%Y%m%d%H%M%S", localtime;

Auch abrufbar als: Unified diff