Class Insert
java.lang.Object
com.northconcepts.datapipeline.jdbc.sql.SqlPart
com.northconcepts.datapipeline.sql.h2.H2SqlPart
com.northconcepts.datapipeline.sql.h2.Insert
Generates an INSERT INTO statement for H2.
Sample Generated SQL:
INSERT INTO `tableName` (`col1`, `col2`, `col3`)
VALUES (val1, val2, val3),
(val1, val2, val3),
(val1, val2, val3),...
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a column-value pair to the current row.voidcollectSqlFragment(CodeWriter writer) Writes this part's SQL to the writer; used bySqlPart.getSqlFragment()and by enclosing parts.Returns the last row.getRows()Returns the list of rows.getTable()Returns the table name.nextRow()Starts a new row for inserting.setPretty(boolean pretty) Indicates if line breaks and indentations should be added to output insert statement (default false).
Example output (pretty = true):
INSERT INTO `tableName` (`col1`, `col2`, `col3`)
VALUES (val1, val2, val3),Methods inherited from class com.northconcepts.datapipeline.sql.h2.H2SqlPart
escapeKeyword, placeBackTicksMethods inherited from class com.northconcepts.datapipeline.jdbc.sql.SqlPart
collectParameterValues, getParameterValues, getSqlFragment, isPretty, printSqlParts, toString
-
Constructor Details
-
Insert
Constructs an Insert for the specified table.- Parameters:
table- the table name
-
-
Method Details
-
setPretty
Indicates if line breaks and indentations should be added to output insert statement (default false).
Example output (pretty = true):
INSERT INTO `tableName` (`col1`, `col2`, `col3`)
VALUES (val1, val2, val3),
(val1, val2, val3),
(val1, val2, val3),...
Example output (pretty = false):
INSERT INTO `tableName` (`col1`, `col2`, `col3`) VALUES (val1, val2, val3), (val1, val2, val3), (val1, val2, val3),... -
getTable
Returns the table name.- Returns:
- the table name
-
nextRow
Starts a new row for inserting.- Returns:
- this instance
-
add
Adds a column-value pair to the current row.- Parameters:
columnName- the column namevalue- the value to insert- Returns:
- this instance
-
getRows
Returns the list of rows.- Returns:
- the list of rows
-
getLastRow
Returns the last row.- Returns:
- the last row
-
collectSqlFragment
Description copied from class:SqlPartWrites this part's SQL to the writer; used bySqlPart.getSqlFragment()and by enclosing parts.- Specified by:
collectSqlFragmentin classSqlPart
-