Skip to content

Obviate.io

To anticipate and prevent

DB2 LUW vs zOS: Selecting from nested subselect

Posted on 2010-02-17 By John No Comments on DB2 LUW vs zOS: Selecting from nested subselect

SQL0104N An unexpected token “” was found following “”. Expected tokens may include: “CORRELATION NAME”. SQLSTATE=42601

This was the error that I got while attempting to execute a stored procedure under DB2 v8.1 for z/OS. Being quite confused about it, I googled for the answer. I didn’t find one, but I did find this google groups post which made mention of it.

Basically, the situation was that I had

SELECT COUNT(*) FROM

(

SELECT …

UNION

SELECT …

)

And while that works just fine under LUW, z/OS doesn’t like it. The simple solution is to add “AS TBL_1”, or any other name to the parenthetical subselect, which I have done below. Both commands work just fine in LUW, but if you are working under z/OS (or at least version 8.1) you will need to use the bottom example.

SELECT COUNT(*) FROM

(

SELECT …

UNION

SELECT …

) AS TBL_1

Database Tags:db2, luw, zos

Post navigation

Previous Post: Recipe: Brett’s Kit Kat Ice Cream Pie
Next Post: I hate people; they make me sick

Related Posts

Wrapping my brain around DynamoDB Cloud
Error: SQL1159 Initialization error with DB2 .NET Data Provider, reason code 10, tokens 0.0.0, 9.7.0 Database
(Re-)Introducing PDNSOps Code
Serendipity to WordPress – Changing table prefix Database
In MySQL: x^y != x raised to the y Database
From the “all-your-databases-are-belong-to-me” department… Database

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2026 Obviate.io.

Powered by PressBook Masonry Dark