Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision e2332bfd

Von Sven Schöling vor fast 8 Jahren hinzugefügt

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

DB Handling: Einige executes mit Fehlerbehandlung versehen

Unterschiede anzeigen:

SL/Controller/CsvImport.pm
8 8
use SL::DB::CsvImportReport;
9 9
use SL::DB::Unit;
10 10
use SL::DB::Helper::Paginated ();
11
use SL::DBUtils qw(do_statement);
11 12
use SL::Helper::Flash;
12 13
use SL::Locale::String;
13 14
use SL::SessionFile;
......
544 545
      push @raw_methods,  $self->raw_data_headers->{headers}->[$i];
545 546
    }
546 547

  
547
    $sth->execute($report->id, $_, 0, $headers[$_]) for 0 .. $#headers;
548
    do_statement($::form, $sth, $query, $report->id, $_, 0, $headers[$_]) for 0 .. $#headers;
548 549

  
549 550
    # col offsets
550 551
    my $o1 =       @info_methods;
......
554 555
      $self->track_progress(progress => $row / @{ $self->data } * 100) if $row % 1000 == 0;
555 556
      my $data_row = $self->{data}[$row];
556 557

  
557
      $sth->execute($report->id,       $_, $row + 1, $data_row->{info_data}{ $info_methods[$_] }) for 0 .. $#info_methods;
558
      $sth->execute($report->id, $o1 + $_, $row + 1, $data_row->{object}->${ \ $methods[$_] })    for 0 .. $#methods;
559
      $sth->execute($report->id, $o2 + $_, $row + 1, $data_row->{raw_data}{ $raw_methods[$_] })   for 0 .. $#raw_methods;
558
      do_statement($::form, $sth, $query, $report->id,       $_, $row + 1, $data_row->{info_data}{ $info_methods[$_] }) for 0 .. $#info_methods;
559
      do_statement($::form, $sth, $query, $report->id, $o1 + $_, $row + 1, $data_row->{object}->${ \ $methods[$_] })    for 0 .. $#methods;
560
      do_statement($::form, $sth, $query, $report->id, $o2 + $_, $row + 1, $data_row->{raw_data}{ $raw_methods[$_] })   for 0 .. $#raw_methods;
560 561

  
561
      $sth2->execute($report->id, $row + 1, 'information', $_) for @{ $data_row->{information} || [] };
562
      $sth2->execute($report->id, $row + 1, 'errors', $_)      for @{ $data_row->{errors}      || [] };
562
      do_statement($::form, $sth2, $query2, $report->id, $row + 1, 'information', $_) for @{ $data_row->{information} || [] };
563
      do_statement($::form, $sth2, $query2, $report->id, $row + 1, 'errors', $_)      for @{ $data_row->{errors}      || [] };
563 564
    }
564 565
    1;
565 566
  }) or do { die SL::DB->client->error };
......
623 624

  
624 625
    for my $i (0 .. $#{ $self->worker->profile }) {
625 626
      my $row_ident = $self->worker->profile->[$i]->{row_ident};
626
      $sth->execute($report->id, $_, $i, $headers->{$row_ident}->[$_]) for 0 .. $#{ $headers->{$row_ident} };
627
      do_statement($::form, $sth, $query, $report->id, $_, $i, $headers->{$row_ident}->[$_]) for 0 .. $#{ $headers->{$row_ident} };
627 628
    }
628 629

  
629 630
    # col offsets
......
647 648
      my $o1 = $off1->{$row_ident};
648 649
      my $o2 = $off2->{$row_ident};
649 650

  
650
      $sth->execute($report->id,       $_, $row + $n_header_rows, $data_row->{info_data}{ $info_methods->{$row_ident}->[$_] }) for 0 .. $#{ $info_methods->{$row_ident} };
651
      $sth->execute($report->id, $o1 + $_, $row + $n_header_rows, $data_row->{object}->${ \ $methods->{$row_ident}->[$_] })    for 0 .. $#{ $methods->{$row_ident} };
652
      $sth->execute($report->id, $o2 + $_, $row + $n_header_rows, $data_row->{raw_data}{ $raw_methods->{$row_ident}->[$_] })   for 0 .. $#{ $raw_methods->{$row_ident} };
651
      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} };
652
      do_statement($::form, $sth, $query, $report->id, $o1 + $_, $row + $n_header_rows, $data_row->{object}->${ \ $methods->{$row_ident}->[$_] })    for 0 .. $#{ $methods->{$row_ident} };
653
      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} };
653 654

  
654
      $sth2->execute($report->id, $row + $n_header_rows, 'information', $_) for @{ $data_row->{information} || [] };
655
      $sth2->execute($report->id, $row + $n_header_rows, 'errors', $_)      for @{ $data_row->{errors}      || [] };
655
      do_statement($::form, $sth2, $query2, $report->id, $row + $n_header_rows, 'information', $_) for @{ $data_row->{information} || [] };
656
      do_statement($::form, $sth2, $query2, $report->id, $row + $n_header_rows, 'errors', $_)      for @{ $data_row->{errors}      || [] };
656 657
    }
657 658
    1;
658 659
  }) or do { die SL::DB->client->error };
SL/DB/Helper/ActsAsList.pm
7 7
                 get_previous_in_list get_next_in_list get_full_list);
8 8

  
9 9
use Carp;
10
use SL::X;
10 11

  
11 12
my %list_spec;
12 13

  
......
145 146
    my $sth   = $self->db->dbh->prepare($query) || die $self->db->dbh->errstr;
146 147

  
147 148
    foreach my $new_position (1 .. scalar(@ids)) {
148
      $sth->execute($new_position, $ids[$new_position - 1]) || die $sth->errstr;
149
      $sth->execute($new_position, $ids[$new_position - 1]) || die SL::X::DBUtilsError->new(error => $sth->errstr);
149 150
    }
150 151

  
151 152
    $sth->finish;
SL/GoBD.pm
549 549
  my $query = "SELECT " . join(', ', @select_tokens) . " FROM $table $where_clause";
550 550

  
551 551
  my $sth = $::form->get_standard_dbh->prepare($query);
552
  $sth->execute(@values) or die "error executing query $query: " . $sth->errstr;
552
  $sth->execute(@values) or $::form->dberror($query);
553 553

  
554 554
  while (my $row = $sth->fetch) {
555 555
    for my $keep_col (@{ $known_tables{$table}{keep} || [] }) {
SL/IC.pm
762 762
    p.id IN ($in)
763 763
SQL
764 764

  
765
  my $sth_tax = prepare_query($::form, $dbh, <<SQL);
765
  my $query_tax = <<SQL;
766 766
    SELECT c.accno, t.taxdescription AS description, t.rate, t.taxnumber
767 767
    FROM tax t
768 768
    LEFT JOIN chart c ON c.id = t.chart_id
......
772 772
       WHERE tk.chart_id = ? AND startdate <= ?
773 773
       ORDER BY startdate DESC LIMIT 1)
774 774
SQL
775
  my $sth_tax = prepare_query($::form, $dbh, $query_tax);
775 776

  
776 777
  while (my ($index => $part_id) = each %args) {
777 778
    my $ref = $accno_by_part{$part_id} or next;
......
787 788

  
788 789
    $form->{"${_}_accno_$index"} = $accounts{"${_}_accno"} for qw(inventory income expense);
789 790

  
790
    $sth_tax->execute($accounts{$inc_exp}, quote_db_date($transdate));
791
    $sth_tax->execute($accounts{$inc_exp}, quote_db_date($transdate)) || $::form->dberror($query_tax);
791 792
    $ref = $sth_tax->fetchrow_hashref or next;
792 793

  
793 794
    $form->{"taxaccounts_$index"} = $ref->{"accno"};
SL/SEPA.pm
168 168
      $transfer->{reference} = "${invnumber}-${num_payments}";
169 169
    }
170 170

  
171
    $h_item_id->execute();
171
    $h_item_id->execute() || $::form->dberror($q_item_id);
172 172
    my ($item_id)      = $h_item_id->fetchrow_array();
173 173

  
174 174
    my $end_to_end_id  = strftime "LXO%Y%m%d%H%M%S", localtime;

Auch abrufbar als: Unified diff