Home > Software engineering >  Column or global variable not found db2
Column or global variable not found db2

Time:10-26

I have a issue with DB2.

I have two libraries with the same structure database. The only one difference is the data.

When i try this sql request for the first library, it's work

SELECT *
FROM Z24FR.CLIENT, Z24FR.EMPLOYE
WHERE CLIENT.CLINUM = EMPLOYE.CLINUM

but when i try with the other library, i have this error.

SELECT *
FROM Z24UK.CLIENT, Z24UK.EMPLOYE
WHERE CLIENT.CLINUM = EMPLOYE.CLINUM
Column or global variable CLINUM not found.
CLINUM was not found as a column of table *N in *N and was not found as a global variable in *N. If the table is *N, CLINUM is not a column of any table or view that can be referenced. 

I check the CLIENT and EMPLOYE tables and they have the column with data.

Thank you in advance for your answer

CodePudding user response:

The way you qualify columns depends on the way tables are "declared"

see Table designators

So if you want something common you can code

SELECT *
FROM Z24xx.CLIENT CLIENT, Z24xx.EMPLOYE EMPLOYE
WHERE CLIENT.CLINUM = EMPLOYE.CLINUM

Or because comma notation is old and not really readable

SELECT
  *
FROM Z24xx.CLIENT CLIENT
  inner join Z24xx.EMPLOYE EMPLOYE on CLIENT.CLINUM = EMPLOYE.CLINUM
  • Related