public class PostgreSqlUpsertWriter extends PostgreSqlInsertWriter
DataEndpoint.State
batchedInserts, batchSize, pretty, tableName
currentRecord
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEY
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZE
id, log, name, TIMESTAMP_FORMAT
Constructor and Description |
---|
PostgreSqlUpsertWriter(String table,
File file,
boolean append,
List<String> keyFieldNames) |
PostgreSqlUpsertWriter(String table,
File file,
boolean append,
String... keyFieldNames) |
PostgreSqlUpsertWriter(String table,
File file,
List<String> keyFieldNames) |
PostgreSqlUpsertWriter(String table,
File file,
String... keyFieldNames) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Indicates that this endpoint has finished reading or writing.
|
ConflictAction |
getConflictAction() |
List<String> |
getKeyFieldNames() |
PostgreSqlUpsertWriter |
setBatchSize(int batchSize)
Sets the number of records to chunk together in batch upserts.
|
PostgreSqlUpsertWriter |
setConflictAction(ConflictAction conflictAction)
Indicates the action to perform on conflict (default ConflictAction.UPDATE).
|
PostgreSqlUpsertWriter |
setPretty(boolean pretty)
Indicates if line breaks and indentations should be added to output upsert statement (default false).
Example output (pretty = true): INSERT INTO "tableName" ("col1", "col2", "col3") |
protected void |
writeRecord(Record record) |
addExceptionProperties, getBatchSize, getSqlValueLiteral, getTableName, isBatchMode, isPretty, setFieldNamesInFirstRow
getFile, getWriter, isAppend, isAutoCloseWriter, isFieldNamesInFirstRow, isFlushOnWrite, setAutoCloseWriter, setFlushOnWrite, write
open, writeImpl
available, getNestedEndpoint, getNestedWriter, getRootEndpoint, getRootWriter
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toString
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
public PostgreSqlUpsertWriter(String table, File file, boolean append, String... keyFieldNames)
public PostgreSqlUpsertWriter(String table, File file, boolean append, List<String> keyFieldNames)
public PostgreSqlUpsertWriter(String table, File file, String... keyFieldNames)
protected void writeRecord(Record record) throws Throwable
writeRecord
in class PostgreSqlInsertWriter
Throwable
public void close()
DataEndpoint
close
in class PostgreSqlInsertWriter
public PostgreSqlUpsertWriter setPretty(boolean pretty)
INSERT INTO "tableName" ("col1", "col2", "col3")
VALUES (val1, val2, val3),
(val1, val2, val3),
(val1, val2, val3)
ON CONFLICT ("id") DO UPDATE SET "col1" = EXCLUDED."col1", "col2" = EXCLUDED."col2", "col3" = EXCLUDED."col3";
INSERT INTO "tableName" ("col1", "col2", "col3") VALUES (val1, val2, val3), (val1, val2, val3), (val1, val2, val3) ON CONFLICT ("id") DO UPDATE SET "col1" = EXCLUDED."col1", "col2" = EXCLUDED."col2", "col3" = EXCLUDED."col3";
setPretty
in class PostgreSqlInsertWriter
public PostgreSqlUpsertWriter setBatchSize(int batchSize)
INSERT INTO "tableName" ("col1", "col2", "col3")
VALUES (val1, val2, val3),
(val1, val2, val3),
ON CONFLICT ("id") DO UPDATE SET "col1" = EXCLUDED."col1", "col2" = EXCLUDED."col2", "col3" = EXCLUDED."col3";
INSERT INTO "tableName" ("col1", "col2", "col3") VALUES (val1, val2, val3) ON CONFLICT ("id") DO UPDATE SET "col1" = EXCLUDED."col1", "col2" = EXCLUDED."col2", "col3" = EXCLUDED."col3";
INSERT INTO "tableName" ("col1", "col2", "col3") VALUES (val1, val2, val3) ON CONFLICT ("id") DO UPDATE SET "col1" = EXCLUDED."col1", "col2" = EXCLUDED."col2", "col3" = EXCLUDED."col3";
setBatchSize
in class PostgreSqlInsertWriter
public ConflictAction getConflictAction()
public PostgreSqlUpsertWriter setConflictAction(ConflictAction conflictAction)
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.