> This page location: PostgreSQL PL/pgSQL > Row Types
> Full Neon documentation index: https://neon.com/docs/llms.txt

# PL/pgSQL Row Types

**Summary**: in this tutorial, you will learn how to use the PL/pgSQL row types to declare row variables that hold a complete row of a result set.

## Introduction to PL/pgSQL row types

Row variables or row-type variables are variables of composite types that can store the entire rows of a result set.

These row variables can hold the entire row returned by the [`select into`](https://neon.com/postgresql/postgresql-plpgsql/pl-pgsql-select-into/) or `for` statement.

Here's the syntax for [declaring a row variable](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-variables):

```sql
row_variable table_name%ROWTYPE;
row_variable view_name%ROWTYPE;
```

In this syntax:

- First, specify the variable name.
- Second, provide the name of a table or view followed by `%` and `ROWTYPE`.

To access the individual field of a row variable, you use the dot notation (`.`) as follows:

```sql
row_variable.field_name
```

## PL/pgSQL row-type variable example

We'll use the `actor` table from the [sample database](../postgresql-getting-started/postgresql-sample-database) to show how row types work:

![](https://neon.com/postgresqltutorial/actor.png)
The following example retrieves the row with id 10 from the actor table and assigns it to a row variable:

```plsql
do
$$
declare
   selected_actor actor%rowtype;
begin
   -- select actor with id 10
   select *
   from actor
   into selected_actor
   where actor_id = 10;

   -- show the number of actor
   raise notice 'The actor name is % %',
      selected_actor.first_name,
      selected_actor.last_name;
end;
$$;
```

How it works.

- First, declare a row variable called `selected_actor` with the same type as the row in the `actor` table.
- Second, assign the row whose value in the `actor_id` column is 10 to the `selected_actor` variable using the [`select into`](https://neon.com/postgresql/postgresql-plpgsql/pl-pgsql-select-into/) statement.
- Third, show the first and last names of the selected actor using the `raise notice` statement.

## Summary

- Use row type variables (`%ROWTYPE`) to hold a row of a result set returned by the `select into` statement.

---

## Related docs (PostgreSQL PL/pgSQL)

- [Introduction](https://neon.com/postgresql/postgresql-plpgsql/introduction-to-postgresql-stored-procedures)
- [Block Structure](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-block-structure)
- [Variables](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-variables)
- [Constants](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-constants)
- [IF-ELSE Statements](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-if-else-statements)
- [CASE Statement](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-case-statement)
- [Loop Statements](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-loop-statements)
- [FOR Loop](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-for-loop)
- [WHILE Loop](https://neon.com/postgresql/postgresql-plpgsql/pl-pgsql-while-loop)
- [EXIT Statement](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-exit)
- [CONTINUE Statement](https://neon.com/postgresql/postgresql-plpgsql/pl-pgsql-continue)
- [Cursor](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-cursor)
- [Function Parameters](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-function-parameters)
- [Function Overloading](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-function-overloading)
- [Function Returns Table](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-function-returns-a-table)
- [Returns SETOF](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-returns-setof)
- [Record Types](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-record-types)
- [Error Messages](https://neon.com/postgresql/postgresql-plpgsql/plpgsql-errors-messages)
- [Exception Handling](https://neon.com/postgresql/postgresql-plpgsql/postgresql-exception)
- [CREATE FUNCTION](https://neon.com/postgresql/postgresql-plpgsql/postgresql-create-function)
- [CREATE PROCEDURE](https://neon.com/postgresql/postgresql-plpgsql/postgresql-create-procedure)
- [DROP FUNCTION](https://neon.com/postgresql/postgresql-plpgsql/postgresql-drop-function)
- [DROP PROCEDURE](https://neon.com/postgresql/postgresql-plpgsql/postgresql-drop-procedure)
- [Stored Procedure with INOUT Parameters](https://neon.com/postgresql/postgresql-plpgsql/postgresql-stored-procedure-with-inout-parameters)
- [Introduction to Stored Procedures](https://neon.com/postgresql/postgresql-plpgsql/introduction-to-postgresql-stored-procedures)
- [SELECT INTO](https://neon.com/postgresql/postgresql-plpgsql/pl-pgsql-select-into)
- [ASSERT Statement](https://neon.com/postgresql/postgresql-plpgsql/pl-pgsql-assert)
- [Dollar-Quoted String Constants](https://neon.com/postgresql/postgresql-plpgsql/dollar-quoted-string-constants)
