NAME
DBIx::DataModel::Schema::ResultAs::Correlated_update - update from a SELECT query
SYNOPSIS
my $count_updates = $schema->join(qw/Activity employee department/)->select(
-columns => [qw/d_birth d_begin dpt_name/],
-result_as => [correlated_update =>
{'T_Activity.remark' => "'started in ' || dpt_name || ' at age ' || d_begin-d_birth"}
]);
DESCRIPTION
Performs a "correlated update", i.e. an update operation on the result of a SELECT query. Not all DBMS support this feature. Oracle does; for others, check your documentation.
The syntax is
$source->select(..., -result_as => [correlated_update => \%columns_to_set]);
which executes an SQL statement of shape :
UPDATE (<select query>) SET k1=v1, k2=v2, ...
where k1, v1, k2, v2, etc. are keys and values of %columns_to_set. Note that unlike the regular UPDATE METHOD, here values v1, v2, ... are treated as literals, not bind values, because the point of such correlated updates is to take values from joined tables for updating columns in the main table.
The return value is the number of updated records.