php + unixODBC + DB2 + DESCRIBE = 令牌无效?

发布于 2024-07-06 02:13:42 字数 392 浏览 5 评论 0原文

我尝试运行的代码:

$query = "DESCRIBE TABLE TABLENAME";
$result = odbc_exec($h, $query);

结果:

PHP 警告:odbc_exec():SQL 错误:[unixODBC][IBM][iSeries Access ODBC 驱动程序][DB2 UDB]SQL0104 - 标记 TABLENAME 无效。 有效的 标记:INTO.,SQLExecDirect 中的 SQL 状态 37000 ...

同一连接上的 SELECT、INSERT、UPDATE 或 DELETE 查询没有其他问题。 这是语法错误吗?

Code I am trying to run:

$query = "DESCRIBE TABLE TABLENAME";
$result = odbc_exec($h, $query);

The result:

PHP Warning: odbc_exec(): SQL error: [unixODBC][IBM][iSeries Access
ODBC Driver][DB2 UDB]SQL0104 - Token TABLENAME was not valid. Valid
tokens: INTO., SQL state 37000 in SQLExecDirect in ...

There were no other problems with SELECT, INSERT, UPDATE or DELETE queries on the same connection. Is this a syntax error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

缺⑴份安定 2024-07-13 02:13:42

DB2 的 iSeries 风格不支持 SQL DESCRIBE 语句。 相反,您必须查询系统表:

select * from qsys2.columns where table_schema = 'my_schema' and table_name = 'my_table'

The iSeries flavor of DB2 does not support the SQL DESCRIBE statement. Instead, you have to query the system table:

select * from qsys2.columns where table_schema = 'my_schema' and table_name = 'my_table'
断舍离 2024-07-13 02:13:42

该语句只能嵌入到应用程序中。 它是无法动态准备的可执行语句。 不得在 Java 中指定它。

来自 iSeries DB2 SQL 参考。

This statement can only be embedded in an application program. It is an executable statement that cannot be dynamically prepared. It must not be specified in Java.

From the iSeries DB2 SQL Reference.

还给你自由 2024-07-13 02:13:42

对我来说,您似乎需要为语句提供一种返回值“Valid tokens: INTO”的方法,告诉我这一点。 我以前没有使用过 DESCRIBE,但我想它会返回一些东西。

Interactive SQL 不允许使用该命令,因此我无法为您提供更多帮助。

顺便说一句,将 iSeries 标签添加到您的问题中。 这样你可能会得到更多答案。

To me it looks like you need to provide a way for the statement to return a value "Valid tokens: INTO" tells me that. I haven't used DESCRIBE before, but I would imagine that it returns something.

Interactive SQL doesn't allow the command so I can't really help you much further than that.

BTW, add the iSeries tag to your question. You might get a few more answers that way.

べ繥欢鉨o。 2024-07-13 02:13:42

如果您只需要列名,请尝试

select * from <TABLE> where 0 = 1

我不知道如何获取列类型、索引、键等

If you just need the column names try

select * from <TABLE> where 0 = 1

I don't know how to get the column types, indexes, keys, &c

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文