Lines 8-13
return {
Link Here
|
8 |
my ($args) = @_; |
8 |
my ($args) = @_; |
9 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
9 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
10 |
|
10 |
|
|
|
11 |
my $sth = $dbh->prepare( |
12 |
q{ |
13 |
SELECT COUNT(*) FROM illrequests WHERE borrowernumber NOT IN (SELECT borrowernumber FROM borrowers) |
14 |
} |
15 |
); |
16 |
$sth->execute; |
17 |
my $count = $sth->fetchrow_array; |
18 |
|
19 |
if ($count) { |
20 |
say_warning( $out, "Found $count illrequests with a borrowernumber that doesn't exist in borrowers" ); |
21 |
$dbh->do( |
22 |
q{ UPDATE illrequests SET borrowernumber = NULL WHERE borrowernumber NOT IN (SELECT borrowernumber FROM borrowers) } |
23 |
); |
24 |
say_info( $out, "Set those borrowernumbers to NULL" ); |
25 |
} |
26 |
|
11 |
$dbh->do(q{ ALTER TABLE illrequests DROP FOREIGN KEY illrequests_bnfk }); |
27 |
$dbh->do(q{ ALTER TABLE illrequests DROP FOREIGN KEY illrequests_bnfk }); |
12 |
$dbh->do( |
28 |
$dbh->do( |
13 |
q{ |
29 |
q{ |
14 |
- |
|
|