unixODBC + PHP,无效字符串或缓冲区长度错误消息

发布于 2024-10-07 08:01:57 字数 350 浏览 0 评论 0原文

我通过 unixODBC 使用 PHP 访问 AS400/DB2
但我的AS400的某些字段名称以“££..”命名(无法更改)
当我尝试从 PHP 页面启动 sql 查询时,

select * from LIBNAME.TABLE where ££FIELD like 'test%'

我总是收到相同的错误消息

SQL 错误:[unixODBC][IBM][System i Access ODBC 驱动程序]字符串或缓冲区长度无效。,SQLExecDirect 中的 SQL 状态 S1090

如果有人有线索。

I access to an AS400/DB2 with PHP via unixODBC
But some field name of my AS400 are named with "££.." (it can't be changed)
And when I tried to launch an sql query from my PHP page

select * from LIBNAME.TABLE where ££FIELD like 'test%'

I always get the same error message

SQL error: [unixODBC][IBM][System i Access ODBC Driver]Invalid string or buffer length., SQL state S1090 in SQLExecDirect

If someone have clue.

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

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

发布评论

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

评论(2

枕梦 2024-10-14 08:01:57

尝试在查询执行之前添加此语句:

setlocale(LC_CTYPE, 'en_US');

有关问题的更详细描述:
http://bugs.centos.org/view.php?id=3187

Try adding this statement before the query execution:

setlocale(LC_CTYPE, 'en_US');

For a more detailed description of the issue:
http://bugs.centos.org/view.php?id=3187

小猫一只 2024-10-14 08:01:57

DB2 应该有某种方法来封装标识符。有些数据库使用双引号,

select * from "tableID" where "fieldID" like 'blah%'

而 mySQL 使用反引号。不确定 DB2,但应该不难找到并尝试。如果这不起作用,请查看是否有一种方法可以用字符串中的十六进制值表示字符。就像“hello\x0A\x0Dthere”一样,“hello”和“there”之间用换行符分隔。您可能只需要找到 £ 的值。

DB2 should have some way of enclosing the identifiers. Some databases use double quotes

select * from "tableID" where "fieldID" like 'blah%'

mySQL uses backticks. Not sure with DB2 but shouldn't be too hard to find out and try. If that doesn't work, see if there is a way to represent characters by hex value in a string. Like 'hello\x0A\x0Dthere' would be the words 'hello' and 'there' separated by a line-break. You may just need to find the value for £.

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