---
name: "DBIx::Class::ResultSetColumn"
section: "3pm"
platform: "linux"
package: "libdbix-class-perl"
version: "0.082844-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/DBIx::Class::ResultSetColumn"
---

# DBIx::Class::ResultSetColumn(3pm)

## NAME

```
  DBIx::Class::ResultSetColumn - helpful methods for messing
  with a single column of the resultset
```

## SYNOPSIS

```
  $rs = $schema->resultset('CD')->search({ artist => 'Tool' });
  $rs_column = $rs->get_column('year');
  $max_year = $rs_column->max; #returns latest year
```

## DESCRIPTION

A convenience class used to perform operations on a specific column of a resultset.

## METHODS

### new

```
  my $obj = DBIx::Class::ResultSetColumn->new($rs, $column);
```

Creates a new resultset column object from the resultset and column passed as params. Used internally by "get\_column" in DBIx::Class::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

- Arguments: none

  - Return Value: $value

  Returns the next value of the column in the resultset (or `"undef"` if there is none).

Much like "next" in DBIx::Class::ResultSet but just returning the one value.

### all

- Arguments: none

  - Return Value: @values

  Returns all values of the column in the resultset (or `"undef"` if there are none).

Much like "all" in DBIx::Class::ResultSet but returns values rather than result objects.

### reset

- Arguments: none

  - Return Value: $self

  Resets the underlying resultset's cursor, so you can iterate through the elements of the column again.

Much like "reset" in DBIx::Class::ResultSet.

### first

- Arguments: none

  - Return Value: $value

  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 DBIx::Class::ResultSet but just returning the one value.

### single

- Arguments: none

  - Return Value: $value

  Much like "single" in DBIx::Class::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

- Arguments: none

  - Return Value: $lowest\_value

  ```
  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

- Arguments: none

  - Return Value: $highest\_value

  ```
  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

- Arguments: none

  - Return Value: $sum\_of\_values

  ```
  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

- Arguments: $function

  - Return Value: $function\_return\_value

  ```
  $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 DBIx::Class::Schema for details.

## FURTHER QUESTIONS?

Check the list of additional DBIC resources.

## COPYRIGHT AND LICENSE

This module is free software copyright by the DBIx::Class (DBIC) authors. You can redistribute it and/or modify it under the same terms as the DBIx::Class library.
