- my $query = "
- UPDATE aqbookfund
- SET bookfundname = ?
- WHERE bookfundid = ?
- AND branchcode= ?
- ";
- warn "name : $bookfundname";
- my $sth=$dbh->prepare($query);
- $sth->execute($bookfundname,$bookfundid,"$branchcode");
-# budgets depending on a bookfund must have the same branchcode
-# if the bookfund branchcode is set
- if (defined $branchcode) {
- $query = "
- UPDATE aqbudget
- SET branchcode = ?
- ";
- $sth=$dbh->prepare($query);
- $sth->execute($branchcode);
+
+ my $retval = $dbh->do("
+ UPDATE aqbookfund
+ SET bookfundname = '$bookfundname',
+ branchcode = '$branchcode'
+ WHERE bookfundid = '$bookfundid'
+ AND branchcode = '$current_branch'
+ ");
+
+ ### $retval
+
+ # budgets depending on a bookfund must have the same branchcode
+
+ # if the bookfund branchcode is set, and previous update is successfull, then update aqbudget.branchcode too.
+ if (defined $branchcode && $retval > 0) {
+ my $query = "UPDATE aqbudget
+ SET branchcode = ?
+ WHERE bookfundid = ? ";
+
+ my $sth=$dbh->prepare($query);
+ $sth->execute($branchcode, $bookfundid) ;