with_deferred_fk_checks for Oracle
Rafael Kitover [Mon, 22 Feb 2010 19:16:07 +0000 (19:16 +0000)]
lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm

index a2b2f90..5973319 100644 (file)
@@ -326,6 +326,25 @@ sub relname_to_table_alias {
   return $new_alias;
 }
 
+=head2 with_deferred_fk_checks
+
+Runs a coderef between:
+
+  alter session set constraints = deferred
+  ...
+  alter session set constraints = immediate
+
+to defer FK checks.
+
+=cut
+
+sub with_deferred_fk_checks {
+  my ($self, $sub) = @_;
+  $self->_do_query('alter session set constraints = deferred');
+  $sub->();
+  $self->_do_query('alter session set constraints = immediate');
+}
+
 =head1 AUTHOR
 
 See L<DBIx::Class/CONTRIBUTORS>.