NAME
DBIO::ResultSetColumn - Convenience wrapper for working with a single ResultSet column
VERSION
version 0.900000
SYNOPSIS
$rs = $schema->resultset('CD')->search({ artist => 'Tool' });
$rs_column = $rs->get_column('year');
$max_year = $rs_column->max; #returns latest year
DESCRIPTION
DBIO::ResultSetColumn is the helper object returned by "get_column" in DBIO::ResultSet. It lets you run column-oriented operations such as aggregates or value iteration without fetching full row objects.
METHODS
new
my $obj = DBIO::ResultSetColumn->new($rs, $column);
Creates a new resultset column object from the resultset and column passed as params. Used internally by "get_column" in DBIO::ResultSet.
new
next
all
reset
first
single
min
max
sum
func
func_rs
throw_exception
_resultset
as_query
- Arguments: none
- Return Value: \[ $sql, @bind_values ]
Returns the SQL query and bind vars associated with the invocant.
This is generally used as the RHS for a subquery.
next
Returns the next value of the column in the resultset (or undef if there is none).
Much like "next" in DBIO::ResultSet but just returning the one value.
all
Returns all values of the column in the resultset (or undef if there are none).
Much like "all" in DBIO::ResultSet but returns values rather than result objects.
reset
Resets the underlying resultset's cursor, so you can iterate through the elements of the column again.
Much like "reset" in DBIO::ResultSet.
first
Resets the underlying resultset and returns the next value of the column in the resultset (or undef if there is none).
Much like "first" in DBIO::ResultSet but just returning the one value.
single
Much like "single" in DBIO::ResultSet fetches one and only one column value using the cursor directly. If additional rows are present a warning is issued before discarding the cursor.
min
my $first_year = $year_col->min();
Wrapper for ->func. Returns the lowest value of the column in the resultset (or undef if there are none).
min_rs
- Arguments: none
- Return Value: $resultset
my $rs = $year_col->min_rs();
Wrapper for ->func_rs for function MIN().
max
my $last_year = $year_col->max();
Wrapper for ->func. Returns the highest value of the column in the resultset (or undef if there are none).
max_rs
- Arguments: none
- Return Value: $resultset
my $rs = $year_col->max_rs();
Wrapper for ->func_rs for function MAX().
sum
my $total = $prices_col->sum();
Wrapper for ->func. Returns the sum of all the values in the column of the resultset. Use on varchar-like columns at your own risk.
sum_rs
- Arguments: none
- Return Value: $resultset
my $rs = $year_col->sum_rs();
Wrapper for ->func_rs for function SUM().
func
$rs = $schema->resultset("CD")->search({});
$length = $rs->get_column('title')->func('LENGTH');
Runs a query using the function on the column and returns the value. Produces the following SQL:
SELECT LENGTH( title ) FROM cd me
func_rs
- Arguments: $function
- Return Value: $resultset
Creates the resultset that func() uses to run its query.
throw_exception
See "throw_exception" in DBIO::Schema for details.
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.