Greetings,

since the re-implementation, the `WITH ...` belongs to the `SELECT`
query only and strictly.

So instead of

WITH ...
INSERT INTO ...
SELECT ... FROM ..

You would need to write

INSERT INTO ...
WITH ...
SELECT ... FROM ..


Best and cheers
Andreas

On Thu, 2025-09-18 at 04:52 -0700, Yury Shafran wrote:
> Hello, everyone!
> 
> I have a query that uses several CTEs followed by an INSERT
> statement. The behaviour differs across H2 versions.
> 
> 1.4.200 - The query works fine.
> 2.2.224 - Some of the CTEs give empty results, so the final result is
> incorrect.
> 2.2.232 - org.h2.jdbc.JdbcSQLSyntaxException: Syntax error in SQL
> statement "with ... <the last CTE>)[*]insert into ..."; expected ",,
> (, SELECT, TABLE, VALUES
> 
> I couldn’t find in the documentation whether INSERT, UPDATE, or
> DELETE are supposed to support CTEs. Could someone clarify the status
> of this feature?
> 
> Thanks in advance!
> -- 
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to [email protected].
> To view this discussion visit
> https://groups.google.com/d/msgid/h2-database/ee024683-790d-4411-91b4-c13f64ffa3fdn%40googlegroups.com
> [1].


[1] 
https://groups.google.com/d/msgid/h2-database/ee024683-790d-4411-91b4-c13f64ffa3fdn%40googlegroups.com
    
https://groups.google.com/d/msgid/h2-database/ee024683-790d-4411-91b4-c13f64ffa3fdn%40googlegroups.com?utm_medium=email&utm_source=footer

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/h2-database/be89f5c84821b228d606564fdb366254be1636e3.camel%40manticore-projects.com.

Reply via email to