diff --git a/plugins/org.jkiss.dbeaver.data.transfer/OSGI-INF/l10n/bundle.properties b/plugins/org.jkiss.dbeaver.data.transfer/OSGI-INF/l10n/bundle.properties
index f51d9b11fddad7b495e13fc1f457d371450cdea1..d2dd78117d9223ece0f8246fbd22b2d04b63d1f3 100644
--- a/plugins/org.jkiss.dbeaver.data.transfer/OSGI-INF/l10n/bundle.properties
+++ b/plugins/org.jkiss.dbeaver.data.transfer/OSGI-INF/l10n/bundle.properties
@@ -76,6 +76,12 @@ dataTransfer.processor.sql.property.rowsInStatement.name=Data rows per statement
dataTransfer.processor.sql.property.rowsInStatement.description=Number of data rows per single insert statement
dataTransfer.processor.sql.property.nativeFormat.name=Native date/time format
dataTransfer.processor.sql.property.nativeFormat.description=Use native date/time format in INSERT statements
+dataTransfer.processor.sql.property.lineBeforeValues.name = Insert line before VALUES
+dataTransfer.processor.sql.property.lineBeforeValues.description = Insert line feeds before keyword VALUES
+dataTransfer.processor.sql.property.lineBeforeRows.name = Insert line before rows
+dataTransfer.processor.sql.property.lineBeforeRows.description = Insert line feeds before each VALUES line (for multi-row inserts)
+dataTransfer.processor.sql.property.keywordCase.name = Keyword case
+dataTransfer.processor.sql.property.keywordCase.description = You can choose lower or upper keyword case
dataTransfer.processor.xml.name=XML
dataTransfer.processor.xml.description=Export to XML file(s)
dataTransfer.processor.xml.propertyGroup.general.label = General
diff --git a/plugins/org.jkiss.dbeaver.data.transfer/plugin.xml b/plugins/org.jkiss.dbeaver.data.transfer/plugin.xml
index df6d2b7568c1a56ad3a551165362a86522ec124a..6b9395e770fea5f8d5c0de4df4dc935309731119 100644
--- a/plugins/org.jkiss.dbeaver.data.transfer/plugin.xml
+++ b/plugins/org.jkiss.dbeaver.data.transfer/plugin.xml
@@ -167,6 +167,10 @@
+
+
+
+
properties = site.getProperties();
+
+ if (properties.containsKey(PROP_INCLUDE_AUTO_GENERATED)) {
+ includeAutoGenerated = CommonUtils.toBoolean(properties.get(PROP_INCLUDE_AUTO_GENERATED));
}
- if (site.getProperties().containsKey(PROP_OMIT_SCHEMA)) {
- omitSchema = CommonUtils.toBoolean(site.getProperties().get(PROP_OMIT_SCHEMA));
+ if (properties.containsKey(PROP_OMIT_SCHEMA)) {
+ omitSchema = CommonUtils.toBoolean(properties.get(PROP_OMIT_SCHEMA));
}
try {
- rowsInStatement = Integer.parseInt(String.valueOf(site.getProperties().get(PROP_ROWS_IN_STATEMENT)));
+ rowsInStatement = Integer.parseInt(String.valueOf(properties.get(PROP_ROWS_IN_STATEMENT)));
} catch (NumberFormatException e) {
rowsInStatement = 10;
}
- useNativeDataFormat = CommonUtils.toBoolean(site.getProperties().get(PROP_DATA_FORMAT));
+ useNativeDataFormat = CommonUtils.toBoolean(properties.get(PROP_DATA_FORMAT));
+ lineBeforeValues = CommonUtils.toBoolean(properties.get(PROP_LINE_BEFORE_VALUES));
+ lineBeforeRows = CommonUtils.toBoolean(properties.get(PROP_LINE_BEFORE_ROWS));
rowDelimiter = GeneralUtils.getDefaultLineSeparator();
dialect = SQLUtils.getDialectFromObject(site.getSource());
+
+ keywordCase = CommonUtils.valueOf(KeywordCase.class, String.valueOf(properties.get(PROP_KEYWORD_CASE)), KeywordCase.upper);
}
@Override
@@ -110,6 +132,7 @@ public class DataExporterSQL extends StreamExporterAbstract {
@Override
public void exportRow(DBCSession session, DBCResultSet resultSet, Object[] row) throws DBException, IOException {
PrintWriter out = getWriter();
+ boolean upperCase = keywordCase == KeywordCase.upper;
SQLDialect.MultiValueInsertMode insertMode = rowsInStatement == 1 ? SQLDialect.MultiValueInsertMode.NOT_SUPPORTED : getMultiValueInsertMode();
if (insertMode == SQLDialect.MultiValueInsertMode.NOT_SUPPORTED) {
rowsInStatement = 1;
@@ -120,12 +143,20 @@ public class DataExporterSQL extends StreamExporterAbstract {
sqlBuffer.setLength(0);
if (rowCount > 0) {
if (insertMode == SQLDialect.MultiValueInsertMode.PLAIN) {
- sqlBuffer.append(");").append(rowDelimiter);
+ sqlBuffer.append(");");
} else if (insertMode == SQLDialect.MultiValueInsertMode.GROUP_ROWS) {
- sqlBuffer.append(";").append(rowDelimiter);
+ sqlBuffer.append(";");
+ }
+ if (lineBeforeRows) {
+ sqlBuffer.append(rowDelimiter);
}
}
- sqlBuffer.append("INSERT INTO ").append(tableName).append(" (");
+ if (upperCase) {
+ sqlBuffer.append(KEYWORD_INSERT_INTO);
+ } else {
+ sqlBuffer.append(KEYWORD_INSERT_INTO.toLowerCase(Locale.ENGLISH));
+ }
+ sqlBuffer.append(" ").append(tableName).append(" (");
boolean hasColumn = false;
for (int i = 0; i < columnsSize; i++) {
DBDAttributeBinding column = columns[i];
@@ -138,11 +169,21 @@ public class DataExporterSQL extends StreamExporterAbstract {
hasColumn = true;
sqlBuffer.append(DBUtils.getQuotedIdentifier(column));
}
- sqlBuffer.append(") VALUES ");
+ sqlBuffer.append(")");
+ if (lineBeforeValues) {
+ sqlBuffer.append(rowDelimiter).append("\t");
+ } else {
+ sqlBuffer.append(" ");
+ }
+ if (upperCase) {
+ sqlBuffer.append(KEYWORD_VALUES);
+ } else {
+ sqlBuffer.append(KEYWORD_VALUES.toLowerCase(Locale.ENGLISH));
+ }
if (insertMode != SQLDialect.MultiValueInsertMode.GROUP_ROWS) {
- sqlBuffer.append("(");
+ sqlBuffer.append("\t(");
}
- if (rowsInStatement > 1) {
+ if (rowsInStatement > 1 && lineBeforeRows) {
sqlBuffer.append(rowDelimiter);
}
out.write(sqlBuffer.toString());
@@ -150,9 +191,15 @@ public class DataExporterSQL extends StreamExporterAbstract {
}
if (insertMode != SQLDialect.MultiValueInsertMode.NOT_SUPPORTED && !firstRow) {
out.write(",");
+ if (lineBeforeRows) {
+ out.write(rowDelimiter);
+ }
}
if (insertMode == SQLDialect.MultiValueInsertMode.GROUP_ROWS) {
- out.write("(");
+ if (lineBeforeRows) {
+ out.write("\t");
+ }
+ out.write(" (");
}
rowCount++;
boolean hasValue = false;
@@ -206,9 +253,8 @@ public class DataExporterSQL extends StreamExporterAbstract {
out.write(")");
}
if (insertMode == SQLDialect.MultiValueInsertMode.NOT_SUPPORTED) {
- out.write(";");
+ out.write(";" + rowDelimiter);
}
- out.write(rowDelimiter);
}
@Override
@@ -265,7 +311,7 @@ public class DataExporterSQL extends StreamExporterAbstract {
private SQLDialect.MultiValueInsertMode getMultiValueInsertMode() {
SQLDialect.MultiValueInsertMode insertMode = SQLDialect.MultiValueInsertMode.NOT_SUPPORTED;
- if (dialect != null) {
+ if (dialect != null && rowsInStatement != 1) {
insertMode = dialect.getMultiValueInsertMode();
}
return insertMode;