Merge 'trunk' into 'sybase'
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Oracle / Generic.pm
index 9c50a3c..8b09f11 100644 (file)
@@ -26,9 +26,6 @@ This class implements autoincrements for Oracle.
 use base qw/DBIx::Class::Storage::DBI/;
 use mro 'c3';
 
-# For ORA_BLOB => 113, ORA_CLOB => 112
-use DBD::Oracle qw( :ora_types );
-
 sub _dbh_last_insert_id {
   my ($self, $dbh, $source, @columns) = @_;
   my @ids = ();
@@ -79,7 +76,7 @@ sub _dbh_get_autoinc_seq {
 
 sub _sequence_fetch {
   my ( $self, $type, $seq ) = @_;
-  my ($id) = $self->dbh->selectrow_array("SELECT ${seq}.${type} FROM DUAL");
+  my ($id) = $self->last_dbh->selectrow_array("SELECT ${seq}.${type} FROM DUAL");
   return $id;
 }
 
@@ -209,12 +206,6 @@ sub connect_call_datetime_setup {
 "alter session set nls_timestamp_tz_format='$timestamp_tz_format'");
 }
 
-sub _svp_begin {
-    my ($self, $name) = @_;
-
-    $self->dbh->do("SAVEPOINT $name");
-}
-
 =head2 source_bind_attributes
 
 Handle LOB types in Oracle.  Under a certain size (4k?), you can get away
@@ -234,6 +225,7 @@ table with more than one LOB column.
 
 sub source_bind_attributes 
 {
+       require DBD::Oracle;
        my $self = shift;
        my($source) = @_;
 
@@ -246,8 +238,9 @@ sub source_bind_attributes
                my %column_bind_attrs = $self->bind_attribute_by_data_type($data_type);
 
                if ($data_type =~ /^[BC]LOB$/i) {
-                       $column_bind_attrs{'ora_type'}
-                               = uc($data_type) eq 'CLOB' ? ORA_CLOB : ORA_BLOB;
+                       $column_bind_attrs{'ora_type'} = uc($data_type) eq 'CLOB' ?
+                               DBD::Oracle::ORA_CLOB() :
+                               DBD::Oracle::ORA_BLOB();
                        $column_bind_attrs{'ora_field'} = $column;
                }
 
@@ -257,6 +250,12 @@ sub source_bind_attributes
        return \%bind_attributes;
 }
 
+sub _svp_begin {
+    my ($self, $name) = @_;
+
+    $self->last_dbh->do("SAVEPOINT $name");
+}
+
 # Oracle automatically releases a savepoint when you start another one with the
 # same name.
 sub _svp_release { 1 }
@@ -264,7 +263,7 @@ sub _svp_release { 1 }
 sub _svp_rollback {
     my ($self, $name) = @_;
 
-    $self->dbh->do("ROLLBACK TO SAVEPOINT $name")
+    $self->last_dbh->do("ROLLBACK TO SAVEPOINT $name")
 }
 
 =head1 AUTHOR