This blog is also available on Gemini (What's Gemini?)

SQL::Functional Cookbook: Inserts


We can build an insert statement easily, too.

my ($sql, @sql\_params) = INSERT INTO 'foo',
    VALUES \[

`INTO` takes a table, which it feeds to `INSERT`. The `INSERT` function likewise takes a list of table columns (in an array ref), followed by `VALUES`, which itself takes an arrayref of the data you're going to put into the columns. All the scalars in that arrayref are passed back in `@sql_params` and filled in as placeholders.

Inserting with a subselect is supported, which we will cover later.