sql - SQL query using Firebird and foreign characters causes a malformed string error
问题描述
I have a simple example that is causing an error using Firebird SQL.
I have a table with a column called Details which is defined as:
DETAILS varchar(261) COLLATE UNICODE
If I try to do the following query:
SELECT a.DETAILS
FROM MODHISTORY a
WHERE
a.DETAILS LIKE '%Â%'
I get the error:
Error: *** IBPP::SQLException ***
Context: Statement::Prepare( SELECT a.DETAILS
FROM MODHISTORY a
WHERE
a.DETAILS LIKE '%Â%'
)
Message: isc_dsql_prepare failed
SQL Message : -104
Invalid token
Engine Code : 335544849
Engine Message :
Malformed string
If I connect to the database using CHARSET=UTF8 in the connection string this error goes away but unfortunately I cannot use UTF8 as the character set when connecting to the database because some other tables contain, for example:
SampleData blob sub_type 1 CHARACTER SET ASCII,
解决方案
我已经按照建议解决了我的问题。我正在绑定参数,现在一切正常
推荐阅读
- mysql - MySQL中的成本总和
- php - 特色图片后没有显示产品描述 - woocommerce 商店
- html - 为什么我的文字没有随着图标改变颜色?
- python - 我可以在 Pycharm for mac 和 windows 中运行相同的 Python 代码吗?
- java - 将类的子类作为类型参数传递(类型参数是子类)
- python - OpenCV中的广义霍夫变换 - 设置角度精度
- angular - 测试主机组件总是给出虚假的“不是已知元素”错误,可能是 karma-webpack 问题?
- pandas - Pandas:使用一列的值根据两列计算表中的行数
- javascript - 如何使用 vanilla Java Script 仅显示所需部分并隐藏所有其他部分?
- c# - 在 HTML 中显示数组中的数组