Skip to content

Commit

Permalink
#36 #59 - add 'insert' statement documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pj-spoelders committed Apr 26, 2021
1 parent 1c90eaa commit b6eec2a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
54 changes: 54 additions & 0 deletions doc/user_guide/statements/insert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# INSERT

You can construct [`INSERT`](https://docs.exasol.com/sql/insert.htm) SQL statements using the `Insert` class.

## Creating `INSERT` Statements

Create an `INSERT` statement:

```java
final Insert insert = StatementFactory.getInstance()
.insertInto("tableName")
.values("value1","value2","value3");
```

Create an `INSERT` statement for specific fields:

```java
final Insert insert = StatementFactory.getInstance()
.insertInto("tableName")
.field("column1", "column2","column3")
.values("value1","value2","value3");
```

### Using Placeholders

```java
insert.valuePlaceholder()
```

### Using Value Tables

```java
final Insert insert = StatementFactory.getInstance().insertInto("tableName");

final ValueTable table = new ValueTable(insert);
table.appendRow("a", "b")
.appendRow("c", "d");

insert.valueTable(table);
```

More info on value tables [value tables](../common_constructs/value_tables.md).

### Rendering `INSERT` Statements

Use the `InsertRenderer` to render `Insert` objects into SQL strings.

```java
final StringRendererConfig config = StringRendererConfig.builder().quoteIdentifiers(true).build();
final InsertRenderer renderer = new InsertRenderer(config);
insert.accept(renderer);
final String sql = renderer.render();
```
For a more general introduction please refer to ["Rendering SQL Statements into Strings"](../rendering.md).
2 changes: 1 addition & 1 deletion doc/user_guide/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Data Query Language (DQL)

Data Modification Language (DML)

- INSERT
- [INSERT](statements/insert.md)
- [MERGE](statements/merge.md)

[fluent]: https://en.wikipedia.org/wiki/Fluent_interface

0 comments on commit b6eec2a

Please sign in to comment.