redbadgers
Programmer
I used to have a dynamic query within a SQL Procedure that used three levels of nested table expression:
SELECT C.col1, C.col2 FROM (
SELECT B.col1, B.col2 FROM (
SELECT A.col1, A.col2 FROM (
SELECT ... FROM xxx
ORDER BY...
) A
ORDER BY...
) B
ORDER BY...
) C
ORDER BY...;
It compiled fine but the performance was poor. So I rewrote it as static SQL.
But now DB2 complained syntax error immediately after the outmost (first) nested table expression:
SQL0104N An unexpected token "(" was found following "C.COL2 FROM".
Expected tokens may include: ",". LINE NUMBER=132. SQLSTATE=42601
When there was only one level of nested table expression it was fine. I could not find in any DB2 documentation that said nested table expression can or cannot have multiple nesting levels. I tried TABLE optional keyword in between FROM and the first open paren but that didn't help.
The entire SQL SELECT statement was about 8K in length.
Both my DB2 client and server are at DB2 V8.1 FP9.
Any tip or reference is appreciated.
Regards, Nancy
SELECT C.col1, C.col2 FROM (
SELECT B.col1, B.col2 FROM (
SELECT A.col1, A.col2 FROM (
SELECT ... FROM xxx
ORDER BY...
) A
ORDER BY...
) B
ORDER BY...
) C
ORDER BY...;
It compiled fine but the performance was poor. So I rewrote it as static SQL.
But now DB2 complained syntax error immediately after the outmost (first) nested table expression:
SQL0104N An unexpected token "(" was found following "C.COL2 FROM".
Expected tokens may include: ",". LINE NUMBER=132. SQLSTATE=42601
When there was only one level of nested table expression it was fine. I could not find in any DB2 documentation that said nested table expression can or cannot have multiple nesting levels. I tried TABLE optional keyword in between FROM and the first open paren but that didn't help.
The entire SQL SELECT statement was about 8K in length.
Both my DB2 client and server are at DB2 V8.1 FP9.
Any tip or reference is appreciated.
Regards, Nancy