问题描述
在FireRobin,我想创建一个视图,其中包含西里尔字母:
CREATE VIEWCyrillicView (PRIM)
AS
SELECT
PRIM
来自ROYALTY
WHERE
(ROYALTY.PRIM ='Кириллица');不幸的是,它导致错误:
blockback
消息:isc_dsql_execute2失败
SQL消息:-607此操作未针对系统表定义。
引擎代码:335544351引擎消息:不成功的元数据
更新STORE RDB $ RELATIONS失败格式错误的字符串
当我用拉丁字母替换西里尔字母时,一切都很好。
此外,我注意到,当我只运行SELECT语句从上面的代码 - 它工作正常,甚至与西里尔字母。
我尝试连接到FireBird使用UTF-8字符集,甚至成功创建了一个视图与西里尔字母。但它是没用的,因为,当我与NONE字符集(右边的)连接,则视图不返回任何行。我已检查视图创建代码,它看起来像这样:
CREATE VIEW CYR(PRIM)
AS
SELECT
PRIM
FROM ROYALTY
WHERE
(ROYALTY.PRIM ='Кириллица')
使用FireRobin连接NONE字符集(右边):
- 可以创建没有西里尔字母的视图
- 不能使用西里尔字母创建视图
li>
- 在使用UTF-8连接并包含西里尔字母时创建的视图不返回任何内容
使用UTF-8字符集(错误的一个)与FIreRibon:
- 可以创建与西里尔字母的视图(实际上不返回任何值)
- 所有列与NONE字符集在结果中不包含任何值
也许有人可以建议我在这里可以做什么?我可以不知何故在where子句中指定不破坏我的编码?也许,在Firebird有一个特殊的符号,像在SQL Server我可以放在解码字符串之前如此:
CREATE VIEW CYR (PRIM)
AS
SELECT
PRIM
FROM ROYALTY
WHERE
(ROYALTY.PRIM =N'Кириллица')
其他信息:
- Firebird 2.5。 2
- 数据库字符集为NONE
- 所有数据库的列最近的为NONE
解决方案问题源于您使用NONE作为数据库默认值,列和连接字符集。它本质上意味着没有字符集,使用任何发送的字节是。对于基本的ASCII集,这通常工作正常。对于其他字符,它可以导致各种奇怪的问题。
对于你的视图定义,你可以通过显式转换为字符集的字符集Cyrillic字符集(win1251),并使用字符集介绍器作为文字:
win1251)= _win1251'< cyrillic chars>'
更好的是使用显式字符集为您的数据库默认,列和连接。使用显式字符集,firebird将在字符集之间为您转换,如果可能。
in FireRobin, I'm trying to create a View that contains Cyrillic letters in it:
CREATE VIEW "CyrillicView" (PRIM)
AS
SELECT
PRIM
FROM ROYALTY
WHERE
(ROYALTY.PRIM = 'Кириллица');
Unfortunately, it results in the Error:
When I replace Cyrillic letters with latin ones everything works just fine. Also, I've noticed that when I run only SELECT statement from the code above - it works fine even with Cyrillic letters in it.
I tryed to connect to FireBird using UTF-8 charset and even successfully created a View with cyrillic letters. But it was useless, because, when I am connecting with "NONE" charset (the right one) then the view does not return any rows at all. I've checked the view creation code and it looks like so:
CREATE VIEW CYR (PRIM)
AS
SELECT
PRIM
FROM ROYALTY
WHERE
(ROYALTY.PRIM = 'Кириллица')
While connecting with NONE charset (the right one) with FireRobin:
- Can write working SELECT queries with cyrillic letters
- Can't create Views using cyrillic letters
- Can create Views without cyrillic letters
- Views that were created while connected with UTF-8 and contain cyrillic letters return nothing
While connecting with UTF-8 charset (the wrong one) with FIreRibon: - Can create Views with cyrillic letters (that actually don't return any values) - All columns with NONE charset contain no values in the results
Maybe someone can suggest what I can do here? Can I somehow specify in the where clause not to ruion my encoding? Maybe, in Firebird there is a special symbol, like in SQL Server I can put before Uncode strings like so:
CREATE VIEW CYR (PRIM)
AS
SELECT
PRIM
FROM ROYALTY
WHERE
(ROYALTY.PRIM = N'Кириллица')
Additional info:
- Firebird 2.5.2
- Database charset is NONE
- All database's columns' charest are NONE
解决方案 The problem stems from your use of NONE as the database default, column and connection character set. It essentially means 'no character set, use whatever bytes sent as is'. For the basic ASCII set this will usually work fine. For other characters it can lead to all kinds of weird problems.
For your view definition you can probably get it to work by explicitly casting the column to a character set with Cyrillic characters (win1251), and by using the character set introducer for the literal:
Cast(theColumn as varchar(100) character set win1251) = _win1251 '<cyrillic chars>'
Better yet would be to use an explicit character set for your database default, columns and connection. With explicit character sets, firebird will convert for you between character sets, if possible.
这篇关于Firebird在WHERE子句中创建一个带有西里尔字母的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!