首页 > 解决方案 > 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,

标签: sqlfirebirdmalformed

解决方案


我已经按照建议解决了我的问题。我正在绑定参数,现在一切正常


推荐阅读