Skip to content

Generate Database-backed Sequences

SequenceTableGenerator reserves a bounded sequence range in a configured database and emits one value per generated record. Use it when identifiers must coordinate with a database-owned sequence rather than only the current task.

In a Platform workspace, the configured environment owns host, credentials, database family, database, and schema. The model references only its logical client ID, so the same descriptor can run against an isolated CI schema and a production-like environment.

sequence-table.xml
1
2
3
4
5
6
<setup>
    <database id="targetDB"/>
    <generate name="orders" count="10" numProcess="4" target="LogExporter">
        <key name="id" generator="SequenceTableGenerator(database='targetDB')"/>
    </generate>
</setup>

The user-facing generator parameter is only database. The runtime injects the current execution context and the current key or variable statement. Resolution checks the explicit database argument first, then the statement and generate source/target context. The root generation count defines the reserved range. The example deliberately requests four workers so the runtime's single-process recommendation is visible in the execution log.

Sequence reservation is intentionally single-process: independent worker processes cannot safely reserve overlapping local windows. The parallelism policy therefore reduces a model using this generator to one process and records the reason.

Database sequence names and target-column resolution depend on the configured database client. Test the final descriptor against the same database family used in production-like execution.

For self-managed or embedded execution, connection properties may still be supplied through the supported environment/property configuration. Keep endpoints and credentials out of the business descriptor; system is only needed when an environment deliberately maps the logical ID to a differently named system profile.