Skip to content

@sqlrooms/duckdb-core / separateLastStatement

Function: separateLastStatement() ​

separateLastStatement(query): SeparatedStatements

Separates a SQL query into preceding statements and the last statement. Useful when you need to execute multiple statements but handle the last one differently (e.g., wrap it in CREATE TABLE, add LIMIT, etc.).

Parameters ​

ParameterTypeDescription
querystringThe SQL query string containing one or more statements

Returns ​

SeparatedStatements

Object containing preceding statements and the last statement

Throws ​

Error if the query contains no statements