[Bio] / Clearinghouse / utils.pm Repository:
ViewVC logotype

Diff of /Clearinghouse/utils.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9, Thu Apr 5 17:15:58 2007 UTC revision 1.10, Fri Mar 27 17:41:35 2015 UTC
# Line 276  Line 276 
276  sub allocate_feature_id  sub allocate_feature_id
277  {  {
278      my($dbh, $genome, $type, $number) = @_;      my($dbh, $genome, $type, $number) = @_;
279      get_lock($dbh, "feature", 10);  
280        $dbh->{RaiseError} = 1;
281        $dbh->begin_work();
282    
283        my $next_id;
284    
285        eval {
286    
287      #if this feature is not in table, insert it      #if this feature is not in table, insert it
288      #get the next value, then update the next value      #get the next value, then update the next value
# Line 294  Line 300 
300          $sth->execute($genome, $type);          $sth->execute($genome, $type);
301      }      }
302    
     my $next_id;  
303      $sth->bind_columns(\$next_id);      $sth->bind_columns(\$next_id);
304      $sth->fetch;      $sth->fetch;
305      my $next_id1 = $next_id+$number;      my $next_id1 = $next_id+$number;
306      my $sth = $dbh->prepare(q{UPDATE next_feature_id set next_id = ? where genome_id=? and type = ? });      my $sth = $dbh->prepare(q{UPDATE next_feature_id set next_id = ? where genome_id=? and type = ? });
307      if (not $sth)      if (not $sth)
308      {      {
         release_lock($dbh, "feature");  
309          die $dbh->errstr;          die $dbh->errstr;
310      }      }
311      $sth->execute($next_id1, $genome, $type);      $sth->execute($next_id1, $genome, $type);
312      $rows = $sth->rows;      $rows = $sth->rows;
313      #print STDERR "update rows = $rows, next_id = $next_id\n";      #print STDERR "update rows = $rows, next_id = $next_id\n";
314      release_lock($dbh, "feature");      };
315    
316        if ($@)
317        {
318            die "error executing queries: $@\n";
319            $dbh->rollback()
320        }
321        else
322        {
323            $dbh->commit();
324        }
325    
326      return $next_id;      return $next_id;
327  }  }

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3