[Bps-public-commit] dbix-searchbuilder branch, insert-from-select, created. 1.59-4-ge745fad
Ruslan Zakirov
ruz at bestpractical.com
Fri Mar 25 09:26:22 EDT 2011
The branch, insert-from-select has been created
at e745fad6c4ff139f3e7d407fd054ac9c389d2286 (commit)
- Log -----------------------------------------------------------------
commit e745fad6c4ff139f3e7d407fd054ac9c389d2286
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Fri Mar 25 16:25:29 2011 +0300
InsertFromSelect method in SB::Handle
diff --git a/lib/DBIx/SearchBuilder/Handle.pm b/lib/DBIx/SearchBuilder/Handle.pm
index 96acb07..51f1e8d 100755
--- a/lib/DBIx/SearchBuilder/Handle.pm
+++ b/lib/DBIx/SearchBuilder/Handle.pm
@@ -384,6 +384,26 @@ sub InsertQueryString {
return ($QueryString, @bind);
}
+=head2 InsertFromSelect
+
+Takes table name, array reference with columns, select query
+and list of bind values. Inserts data select by the query
+into the table.
+
+=cut
+
+sub InsertFromSelect {
+ my ($self, $table, $columns, $query, @binds) = @_;
+
+ $columns = join ', ', @$columns
+ if $columns;
+
+ my $full_query = "INSERT INTO $table";
+ $full_query .= " ($columns)" if $columns;
+ $full_query .= ' '. $query;
+ return $self->SimpleQuery( $full_query, @binds );
+}
+
=head2 UpdateRecordValue
Takes a hash with fields: Table, Column, Value PrimaryKeys, and
diff --git a/lib/DBIx/SearchBuilder/Handle/Oracle.pm b/lib/DBIx/SearchBuilder/Handle/Oracle.pm
index de0a6bf..3e5cc21 100755
--- a/lib/DBIx/SearchBuilder/Handle/Oracle.pm
+++ b/lib/DBIx/SearchBuilder/Handle/Oracle.pm
@@ -118,6 +118,17 @@ sub Insert {
}
+=head2 InsertFromSelect
+
+Customization of L<DBIx::SearchBuilder::Handle/InsertFromSelect>.
+unlike other DBs Oracle needs select query to be in parens.
+
+=cut
+
+sub InsertFromSelect {
+ my ($self, $table, $columns, $query, @binds) = @_;
+ return $self->SUPER::InsertFromSelect( $table, $columns, "($query)", @binds);
+}
=head2 BuildDSN PARAMHASH
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list