[Bio] / FigKernelPackages / DBrtns.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/DBrtns.pm

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

revision 1.8, Tue Jan 25 04:44:22 2005 UTC revision 1.11, Thu Apr 7 17:31:59 2005 UTC
# Line 84  Line 84 
84      }      }
85      else      else
86      {      {
87          return $dbh->do($sql, undef, @bind_values);          my $rc;
88            my $ok = eval {
89                $rc = $dbh->do($sql, undef, @bind_values);
90            };
91    
92            if (!$ok)
93            {
94                confess "query failed: " . substr($sql, 0, 100) . ": $@";
95            }
96            return $rc;
97    
98    
99  #       $sth = $dbh->prepare($sql)  #       $sth = $dbh->prepare($sql)
100  #           or die "prepare failed: $DBI::errstr";  #           or die "prepare failed: $DBI::errstr";
101  #       $sth->execute()  #       $sth->execute()
# Line 127  Line 138 
138      {      {
139          $cmd = "DROP TABLE IF EXISTS $tbl;" ;          $cmd = "DROP TABLE IF EXISTS $tbl;" ;
140      }      }
141        elsif ($dbms eq "Pg")
142        {
143            if ($self->table_exists($tbl))
144            {
145                $cmd = "DROP TABLE $tbl CASCADE;" ;
146            }
147        }
148      else      else
149      {      {
150          if ($self->table_exists($tbl))          if ($self->table_exists($tbl))
# Line 226  Line 244 
244      }      }
245  }  }
246    
247    =pod
248    
249    =head1 get_inserted_id
250    
251    Return the last ID of a row inserted into an autonumber/serial-containing table.
252    
253    =cut
254    
255    sub get_inserted_id
256    {
257        my($self, $table, $sth) = @_;
258        if ($self->{_dbms} eq "Pg")
259        {
260            my $oid = $sth->{pg_oid_status};
261            my $ret = $self->SQL("select id from $table where oid = ?", undef, $oid);
262            return $ret->[0]->[0];
263        }
264        elsif ($self->{_dbms} eq "mysql")
265        {
266            my $id = $self->{_dbh}->{mysql_insertid};
267            # print "mysql got $id\n";
268            return $id;
269        }
270    }
271    
272    
273  #  #
274  # Following are database administration routines. They create an instance of a ServerAdmin class  # Following are database administration routines. They create an instance of a ServerAdmin class
275  # for the appropriate server type (in order to eliminate the if mysql / if pg / etc stuff).  # for the appropriate server type (in order to eliminate the if mysql / if pg / etc stuff).

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.11

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3