为什么我的查询会生成“未定义名称"?SQLCODE -204错误? [英] Why does my query generate an "undefined name" error with SQLCODE -204?
问题描述
这是一个SQL Server查询
This is a SQL Server query
select Letter, COUNT(*)
from #Letters
LEFT JOIN Emp ON Name LIKE Letter + '%'
group by Letter
但是它不能在DB2中运行,并给出错误消息:
but it would not run in DB2, giving an error message:
"MOHIT.#LETTERS"是未定义的名称.SQLCODE= -204,SQLSTATE = 42704,驾驶员= 4.18.60
"MOHIT.#LETTERS" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=4.18.60
推荐答案
您还没有使用#LETTERS表进入数据库和MOHIT库.可能会进入另一个图书馆吗?
You have not table with #LETTERS into your database and into MOHIT Library. May be into a other Library?
注意:#Tablename是SQL Server中的临时表,在DB2中它只是一个表
Note: #Tablename are for temporary table in SQL Server, in DB2 its just a table
注2:在DB2中,"+"不是连接运算符,请使用"||"
Note 2: '+' are not an operator of concatenation in DB2, use '||'
您的查询应该是
select Letter, COUNT(*)
from #Letters
LEFT JOIN Emp ON Name LIKE Letter || '%'
group by Letter
当然,您的表应该存在于已加载的库列表中
Of course your table shoud be exist in list of Library loaded
这篇关于为什么我的查询会生成“未定义名称"?SQLCODE -204错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!