Hi,
I receive the error code SQL0338N if I try to compile this statement
(part of the statement):
... left outer join lateral
(SELECT * FROM LIZSYSABA.VWZL0359TBS WHERE tbs_name = CASE WHEN
MC.type_txt = 'ZAB' THEN 'BII' ELSE 'STD' END) AS TB1
on CASE WHEN MC.fixed_date_dat IS NULL THEN cast('01.01.2007' as date)
+ MC.rel_shift_NR DAY ELSE MC.fixed_date_dat END
= TB1.TBS_START ...
Any hints?
Thanks in advance,
Sascha
Lennart - 27 Jun 2007 19:12 GMT
> Hi,
>
[quoted text clipped - 12 lines]
> Thanks in advance,
> Sascha
[lelle@53dbd181 lelle]$ db2 "? SQL0338N"
SQL0338N An ON clause associated with a JOIN operator or in a
MERGE statement is not valid.
Explanation:
An ON clause associated with a JOIN operator or in a MERGE
statement is not valid for one of the following reasons.
o The ON clause cannot include any subqueries.
o Column references in an ON clause must only reference columns
of tables that are in the scope of the ON clause.
o Scalar fullselects are not allowed in the expressions of an
ON clause.
o A function referenced in an ON clause of a full outer join
must be deterministic and have no external action.
o A dereference operation (->) cannot be used.
o A SQL function or SQL method cannot be used.
o The ON clause cannot include an XMLQUERY or XMLEXISTS
expression.
The statement cannot be processed.
User Response:
Correct the ON clause to reference appropriate columns or delete
any subqueries or scalar fullselects. Remove any dereference
operations, SQL functions, or SQL methods from the ON clause.
If using full outer join ensure that all functions in the ON
clause are deterministic and have no external action.
sqlcode : -338
sqlstate : 42972
Sascha.Moellering@gmail.com - 27 Jun 2007 19:35 GMT
Hi,
thank you. Well, but I don't know how to correct the problem.
Any ideas?
Thank you in advance,
Sascha
> Sascha.Moeller...@gmail.com wrote:
> > Hi,
[quoted text clipped - 56 lines]
>
> sqlstate : 42972
Lennart - 27 Jun 2007 20:15 GMT
> Hi,
>
> thank you. Well, but I don't know how to correct the problem.
>
> Any ideas?
What is MC and how is it involved in the join?
/Lennart
> Thank you in advance,
> Sascha
[quoted text clipped - 59 lines]
>>
>> sqlstate : 42972
Serge Rielau - 27 Jun 2007 20:19 GMT
> Hi,
>
> thank you. Well, but I don't know how to correct the problem.
Eliminate that SELECT * subquery. What is the use of it?
Why not LOJ on the base table?
BTW, which version platform of DB2 is this?
Cheers
Serge

Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Tonkuma - 28 Jun 2007 01:56 GMT
On Jun 28, 2:33 am, "Sascha.Moeller...@gmail.com"
<Sascha.Moeller...@gmail.com> wrote:
> ... left outer join lateral
> (SELECT * FROM LIZSYSABA.VWZL0359TBS WHERE tbs_name = CASE WHEN
> MC.type_txt = 'ZAB' THEN 'BII' ELSE 'STD' END) AS TB1
> on CASE WHEN MC.fixed_date_dat IS NULL THEN cast('01.01.2007' as date)
> + MC.rel_shift_NR DAY ELSE MC.fixed_date_dat END
> = TB1.TBS_START ...
I think ON clause can be make simple by using COALESCE.
ON COALESCE(MC.fixed_date_dat, cast('01.01.2007' as date) +
MC.rel_shift_NR DAY)
= TB1.TBS_START ...