Revision 41276623
Von Niclas Zimmermann 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 |
# @charset: utf-8 |
|
5 | 4 |
|
6 |
use utf8; |
|
7 |
use strict; |
|
8 |
|
|
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 |
} |
|
5 |
package SL::DBUpgrade2::rm_whitespaces; |
|
15 | 6 |
|
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 |
} |
|
7 |
use parent qw(SL::DBUpgrade2::Base); |
|
25 | 8 |
|
9 |
use utf8; |
|
10 |
use strict; |
|
26 | 11 |
|
27 |
sub do_update { |
|
12 |
sub run { |
|
13 |
my ($self) = @_; |
|
28 | 14 |
my $query = qq|UPDATE ar SET curr = RTRIM(LTRIM(curr))|; |
29 |
do_query($query);
|
|
15 |
$self->db_query($query);
|
|
30 | 16 |
$query = qq|UPDATE ap SET curr = RTRIM(LTRIM(curr))|; |
31 |
do_query($query);
|
|
17 |
$self->db_query($query);
|
|
32 | 18 |
$query = qq|UPDATE oe SET curr = RTRIM(LTRIM(curr))|; |
33 |
do_query($query);
|
|
19 |
$self->db_query($query);
|
|
34 | 20 |
$query = qq|UPDATE customer SET curr = RTRIM(LTRIM(curr))|; |
35 |
do_query($query);
|
|
21 |
$self->db_query($query);
|
|
36 | 22 |
$query = qq|UPDATE delivery_orders SET curr = RTRIM(LTRIM(curr))|; |
37 |
do_query($query);
|
|
23 |
$self->db_query($query);
|
|
38 | 24 |
$query = qq|UPDATE exchangerate SET curr = RTRIM(LTRIM(curr))|; |
39 |
do_query($query);
|
|
25 |
$self->db_query($query);
|
|
40 | 26 |
$query = qq|UPDATE vendor SET curr = RTRIM(LTRIM(curr))|; |
41 |
do_query($query);
|
|
27 |
$self->db_query($query);
|
|
42 | 28 |
|
43 | 29 |
$query = qq|SELECT curr FROM defaults|; |
44 |
my ($curr) = selectrow_query($self, $dbh, $query);
|
|
30 |
my ($curr) = $self->dbh->selectrow_array($query);
|
|
45 | 31 |
|
46 | 32 |
$curr =~ s/ //g; |
47 | 33 |
|
48 | 34 |
$query = qq|UPDATE defaults SET curr = '$curr'|; |
49 |
do_query($query);
|
|
35 |
$self->db_query($query);
|
|
50 | 36 |
return 1; |
51 | 37 |
}; |
52 | 38 |
|
53 |
return do_update(); |
|
39 |
1; |
Auch abrufbar als: Unified diff
Anpassung Upgrade-Script an neue Synthax
Passt zwei alte Upgrade-Scripte an die neue Synthax an.