NAME
JsonSQL::Param::Insert - JsonSQL::Param::Insert object. Stores a Perl representation of an INSERT statement used by the JsonSQL Insert query object.
VERSION
version 0.41
SYNOPSIS
This module constructs a Perl object representing an SQL INSERT statement and has methods for generating the appropriate SQL statement and bind values for use with the DBI module.
DESCRIPTION
Object properties:
- _insertTable => JsonSQL::Param::Table
- _insertValues => JsonSQL::Param::InsertValues
- _insertReturning => <string>
-
( Note: not currently whitelist validated due to the way this is implemented. Will change in future. )
Structure of INSERT statement:
INSERT INTO <table> ( <columns> ) VALUES ( <parameterized values> )
RETURNING clause
When using the RETURNING clause, the INSERT statement is wrapped in a WITH CTE, so your database has to support this.
WITH insert_q AS (
INSERT INTO <table> ( <columns> ) VALUES ( <parameterized values> )
RETURNING <return columns>
)
SELECT * FROM insert_q
METHODS
Constructor new($inserthashref, $queryObj)
Instantiates and returns a new JsonSQL::Param::Insert object.
$inserthashref => A hashref with the properties needed to construct the object.
$queryObj => A reference to the JsonSQL::Query object that will own this object.
Returns a JsonSQL::Error object on failure.
ObjectMethod get_returning_param_string -> $returningParam
Generates the RETURNING clause from the _insertReturning property.
ObjectMethod get_insert_stmt -> ( $sql, $binds )
Generates the SQL statement represented by the object. Returns:
$sql => An SQL INSERT string.
$binds => An arrayref of parameterized values to pass with the query.
AUTHOR
Chris Hoefler <bhoefler@draper.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Chris Hoefler.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.