Revision 1ee1e429
Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt
sql/Pg-upgrade2/rm_whitespaces.pl | ||
---|---|---|
1 | 1 |
# @tag: rm_whitespaces |
2 | 2 |
# @description: Entfernt mögliche Leerzeichen am Anfang und Ende jeder Währung |
3 | 3 |
# @depends: release_3_0_0 |
4 |
|
|
5 |
package SL::DBUpgrade2::rm_whitespaces; |
|
6 |
|
|
7 |
use parent qw(SL::DBUpgrade2::Base); |
|
4 |
# @charset: utf-8 |
|
8 | 5 |
|
9 | 6 |
use utf8; |
10 | 7 |
use strict; |
11 | 8 |
|
12 |
sub run { |
|
13 |
my ($self) = @_; |
|
9 |
die("This script cannot be run from the command line.") unless ($main::form); |
|
10 |
|
|
11 |
sub mydberror { |
|
12 |
my ($msg) = @_; |
|
13 |
die($dbup_locale->text("Database update error:") . "<br>$msg<br>" . $DBI::errstr); |
|
14 |
} |
|
15 |
|
|
16 |
sub do_query { |
|
17 |
my ($query, $may_fail) = @_; |
|
18 |
|
|
19 |
if (!$dbh->do($query)) { |
|
20 |
mydberror($query) unless ($may_fail); |
|
21 |
$dbh->rollback(); |
|
22 |
$dbh->begin_work(); |
|
23 |
} |
|
24 |
} |
|
25 |
|
|
26 |
|
|
27 |
sub do_update { |
|
14 | 28 |
my $query = qq|UPDATE ar SET curr = RTRIM(LTRIM(curr))|; |
15 |
$self->db_query($query);
|
|
29 |
do_query($query);
|
|
16 | 30 |
$query = qq|UPDATE ap SET curr = RTRIM(LTRIM(curr))|; |
17 |
$self->db_query($query);
|
|
31 |
do_query($query);
|
|
18 | 32 |
$query = qq|UPDATE oe SET curr = RTRIM(LTRIM(curr))|; |
19 |
$self->db_query($query);
|
|
33 |
do_query($query);
|
|
20 | 34 |
$query = qq|UPDATE customer SET curr = RTRIM(LTRIM(curr))|; |
21 |
$self->db_query($query);
|
|
35 |
do_query($query);
|
|
22 | 36 |
$query = qq|UPDATE delivery_orders SET curr = RTRIM(LTRIM(curr))|; |
23 |
$self->db_query($query);
|
|
37 |
do_query($query);
|
|
24 | 38 |
$query = qq|UPDATE exchangerate SET curr = RTRIM(LTRIM(curr))|; |
25 |
$self->db_query($query);
|
|
39 |
do_query($query);
|
|
26 | 40 |
$query = qq|UPDATE vendor SET curr = RTRIM(LTRIM(curr))|; |
27 |
$self->db_query($query);
|
|
41 |
do_query($query);
|
|
28 | 42 |
|
29 | 43 |
$query = qq|SELECT curr FROM defaults|; |
30 |
my ($curr) = $self->dbh->selectrow_array($query);
|
|
44 |
my ($curr) = selectrow_query($self, $dbh, $query);
|
|
31 | 45 |
|
32 | 46 |
$curr =~ s/ //g; |
33 | 47 |
|
34 | 48 |
$query = qq|UPDATE defaults SET curr = '$curr'|; |
35 |
$self->db_query($query);
|
|
49 |
do_query($query);
|
|
36 | 50 |
return 1; |
37 | 51 |
}; |
38 | 52 |
|
39 |
1; |
|
53 |
return do_update(); |
Auch abrufbar als: Unified diff
Revert "Anpassung Upgrade-Script an neue Synthax"
This reverts commit 41276623722df9317163274551400fc42a2722e0.