IBM Db2 网络驱动程序 SQL 错误。找不到表名?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7183433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IBM Db2 net driver SQL error. Not finding table name?
提问by cmck23
from this query:
从这个查询:
select * from table
I get the following error messages:
我收到以下错误消息:
Error: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=webuser.table, DRIVER=4.8.87
SQLState: 42704
ErrorCode: -204
Error: DB2 SQL Error: SQLCODE=-727, SQLSTATE=56098, SQLERRMC=2;-204;42704;webuser.table, DRIVER=4.8.87
SQLState: 56098
ErrorCode: -727
Any suggestions for how to investigate the problem is much appreciated.
非常感谢有关如何调查问题的任何建议。
回答by mwolfetech
At first glance, it seems that DB2 is not finding that table name under the webuser
schema, or the schema of the current connected user does not match the schema for the table. Try:
乍一看,DB2 似乎没有在webuser
模式下找到该表名,或者当前连接用户的模式与表的模式不匹配。尝试:
select * from webuser.table
If that fails, then it probably does not exist under the webuser
schema, so try to find out what schema it does exist under.
如果失败,那么它可能不存在于webuser
模式下,因此尝试找出它确实存在于什么模式下。
You can often find information for sql error codesin the IBM DB2 infocenteror on the DB2 UDB command line like so:
您通常可以在IBM DB2 信息中心或 DB2 UDB 命令行中找到有关sql 错误代码的信息,如下所示:
db2 ? SQL0100
You can look up any error this way:
您可以通过以下方式查找任何错误:
db2 ? SQLnnnnn
where nnnnn
is the error code.
nnnnn
错误代码在哪里。
You can also often find information on sql error code from db2 by searching on google without including the -
since google removes the term with a dash in front from the search results. So, search for sql code 204
and not sql code -204
.
您还可以经常通过在 google 上搜索而不包括从 db2 中找到有关 sql 错误代码的信息,-
因为 google 从搜索结果中删除了前面带有破折号的术语。所以,搜索sql code 204
而不是sql code -204
。
You can usually find a list of all the tables under sysibm.tables
or syscat.tables
depending on what type of system (z/OS or UDB) you are running on, and also depending on if the db2 administrator has restricted access to those catalog tables.
您通常可以找到下的所有表的列表,sysibm.tables
或者syscat.tables
根据您正在运行,并且还取决于如果DB2管理员限制访问这些目录表什么类型的系统(Z / OS或UDB)。
If you are running against a UDB instance, try:
如果您针对 UDB 实例运行,请尝试:
select tabschema, tabname from syscat.tables
I'm assuming of course that you are not expecting the table to be named table
. I would think that is a restricted word under db2 or the SQL-92 standard.
我当然假设您不希望该表被命名为table
。我认为这是 db2 或 SQL-92 标准下的限制词。
If you happen to be running a stored procedure that runs that query, then you may not be seeing the true error from the query. Stored procedures often return a different error code than a query inside the stored procedure would, unless they are programmed to catch and return the sqlcode and sqlstate from the query itself.
如果您碰巧正在运行运行该查询的存储过程,那么您可能不会从查询中看到真正的错误。存储过程通常返回与存储过程中的查询不同的错误代码,除非它们被编程为从查询本身捕获并返回 sqlcode 和 sqlstate。
Additionally, I see that you are getting a sqlcode of -727, with a message code of 2. The documentation for that says:
此外,我看到您收到的 sqlcode 为 -727,消息代码为 2。相关文档说:
An error occurred during implicit system action type action-type . Information returned for the error includes SQLCODE sqlcode , SQLSTATE sqlstate and message tokens token-list .
where the action-type is 2: implicit prepare of a cached dynamic SQL statement
其中 action-type 为 2:缓存动态 SQL 语句的隐式准备
This error information is less straightforward and more tuned for a Database Administrator. It may end up being useful but I would try the other suggestions first. It may mean that certain packages are not bound to the database (like the ones for your net driver) or that certain permissions in the database are not correct or a fixpack was not applied correctly and there are missing database procedures. However, it could also be caused by the -204 and just be a subsequent error.
对于数据库管理员来说,此错误信息不那么直接,而是更适合调整。它最终可能会有用,但我会先尝试其他建议。这可能意味着某些包未绑定到数据库(例如用于您的网络驱动程序的包),或者数据库中的某些权限不正确或未正确应用修复包并且缺少数据库过程。但是,它也可能是由 -204 引起的,并且只是后续错误。
回答by mp31415
SQLCODE=-727, SQLSTATE=56098
may happen if there is a typo in one of the column names in the select statement.
SQLCODE=-727, SQLSTATE=56098
如果 select 语句中的列名称之一有拼写错误,则可能会发生这种情况。