0

Is it possible to create a CTE without a FROM, and if not isn't that the whole point of a CTE in the first place?

WITH cte AS
(
  SELECT 1 AS col1, 2 AS col2
)
SELECT col1, col2 FROM cte;

> ORA-00923: FROM keyword not found where expected

It seems a quick-fix for this is just adding FROM DUAL whenever needed. Is that what's supposed to be done?

David542
  • 104,438
  • 178
  • 489
  • 842

1 Answers1

1

Yes, that's exactly what dual is supposed to be used for.

Selecting from the DUAL table is useful for computing a constant expression with the SELECT statement. Because DUAL has only one row, the constant is returned only once.

https://docs.oracle.com/cd/B19306_01/server.102/b14200/queries009.htm

eaolson
  • 14,717
  • 7
  • 43
  • 58