Revision 9d14fd7e
Von Sven Schöling vor etwa 13 Jahren hinzugefügt
SL/WH.pm | ||
---|---|---|
59 | 59 |
my $employee = SL::DB::Manager::Employee->find_by(login => $::form->{login}); |
60 | 60 |
my ($now) = selectrow_query($::form, $::form->get_standard_dbh, qq|SELECT current_date|); |
61 | 61 |
my @directions = (undef, qw(out in transfer)); |
62 |
my $db = SL::DB->create(undef, 'LXOFFICE'); # get handle for transaction |
|
63 | 62 |
|
64 | 63 |
my $objectify = sub { |
65 | 64 |
my ($transfer, $field, $class, @find_by) = @_; |
... | ... | |
74 | 73 |
return; |
75 | 74 |
}; |
76 | 75 |
|
77 |
$db->begin_work; |
|
78 |
eval { |
|
79 |
|
|
80 |
for my $transfer (@args) { |
|
76 |
my $db = SL::DB::Inventory->new->db; |
|
77 |
$db->do_transaction(sub{ |
|
78 |
while (my $transfer = shift @args) { |
|
81 | 79 |
my ($trans_id) = selectrow_query($::form, $::form->get_standard_dbh, qq|SELECT nextval('id')|); |
82 | 80 |
|
83 | 81 |
my $part = $objectify->($transfer, 'parts', 'SL::DB::Part'); |
... | ... | |
133 | 131 |
)->save; |
134 | 132 |
} |
135 | 133 |
} |
136 |
|
|
137 |
$db->commit; |
|
138 |
|
|
139 |
1; |
|
140 |
} or do { |
|
141 |
$db->rollback; |
|
142 |
die $@; # rethrow |
|
134 |
}) or do { |
|
135 |
$::form->error("Warehouse transfer error: " . join("\n", (split(/\n/, $db->error))[0..2])); |
|
143 | 136 |
}; |
144 | 137 |
|
145 | 138 |
$::lxdebug->leave_sub; |
Auch abrufbar als: Unified diff
DB-Fehler in Transaktion nach oben melden