I am facing the oracle error ORA-00928: missing SELECT keyword
with a query, generated by sqlalchemy. The issue was already described and answered here.
My query looks like:
WITH table2 (id) AS (
SELECT id
FROM table3
)
UPDATE table SET id=1
WHERE EXISTS (
SELECT *
FROM table
WHERE id IN (SELECT id FROM table2)
)
and gets generated by this:
table2 = session.query(table3.id).cte()
update(table).where(exists().where(table.id.in_(table2))).values(id=1)
Now I am wondering how to tell sqlachemy to put the CTEs inside the WHERE
clause and not above the UPDATE
.
UPDATE table SET id=1
WHERE EXISTS (
WITH table2 (id) AS (
SELECT id
FROM table3
)
SELECT *
FROM table
WHERE id IN (SELECT id FROM table2)
)