Quote:
|
Can you tell me how to use the Merge statement with CTE.. one example will be helpful.
|
Please see this thread:
can we use Merge and With Together
My opinions are:
1) Can we use MERGE and WITH(common-table-expression) Together?
No,
Syntax of MERGE doesn't include CTE.
2) If you are using DB2 Version 9.1 for z/OS,
following statement may be possible.
WITH cte AS (...)
SELECT ...
FROM FINAL TABLE(MERGE statement)
3) It may be possible to UPDATE/INSERT in a statement with common-table-expressions, at least on DB2 8.2 or later for LUW.
You can see an example in the thread.