Executes a table-to-table SQL INSERT (or REPLACE) operation based on parameters from the query, optionally deleting the target before inserting, and returns a result value.
INSERTSQL — set as ReportType in def_report.
def Render(self, Param1="", Param2="", Param3="") -> str:
The query must return rows with columns:
| Col | Field | Notes |
|---|---|---|
| 0 | Source table | |
| 1 | Target table | |
| 2 | Insert key columns (comma-separated, or * for all matching columns) |
|
| 3 | Replace key columns (comma-separated) | optional |
| 4 | Replace-with values (comma-separated, CSV-quoted) | optional |
| 5 | WHERE clause for source SELECT | optional |
| 6 | Mode: DELETE, REPLACE, or INSERT (default) |
optional |
| 7 | WHERE clause for DELETE on target | optional |
| 8 | Columns to exclude when key is * |
optional |
| 9 | Column to return from target after insert | optional |
| 10 | ORDER BY clause for return value | optional |
When mode is DELETE, the target table is cleared before the insert. When key is *, matching columns between source and target are determined via information_schema. Returns the value of the return column, or "1" on success.
The INSERT is wrapped in a START TRANSACTION / COMMIT block. Special replacement values NOW(), UUID(), and backtick-quoted expressions are handled without quoting.