我在 postgresql 中设置外部数据包装器,使用 freetds 连接到 SQL Server,并tds_fdw
在 postgresql 中安装了扩展,但是当从外部表中选择数据时,代码总是会引发这个 DB-Library 错误:
DB #: 4075 错误:
USE 数据库语句失败,因为旧客户端驱动程序无法识别数据库排序规则 Persian_100_CI_AI。尝试升级客户端操作系统或对数据库客户端软件应用服务更新,或使用不同的排序规则。有关更改排序规则的详细信息,请参阅 SQL Server 联机丛书
我深入研究了位于的 net 和配置 freets.conf 文件/etc/freetds
[global]
# TDS protocol version
; tds version = 8.0
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
; timeout = 10
; connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512
client charset = UTF-8
# A typical Sybase server
[egServer50]
host = symachine.domain.com
port = 5000
tds version = 5.0
# A typical Microsoft server
[mssql]
host = 192.168.x.x
port = 1433
tds version = 7.1
这是我在 postgres 中的 sql 代码
CREATE SERVER prs_server
FOREIGN DATA WRAPPER tds_fdw
OPTIONS (servername '192.168.x.x', port '1433',database 'prs_bpms', tds_version '7.1', msg_handler 'notice');
CREATE USER MAPPING FOR postgres
SERVER prs_server
OPTIONS (username 'bpms', password 'xxxx');
CREATE FOREIGN TABLE prs_table (
FirstName varchar null,
LastName varchar nuul,
SSN varchar not null
)
SERVER prs_server
OPTIONS (query 'SELECT top 10 [FirstName],[LastName],[SSN] FROM [dbo].[prs_Personnel] ');
SELECT * FROM prs_table;
而且我还需要使用 where 子句,但反斜杠转义字符'select from where ssn = \'1234\''
不起作用并给出语法错误。
任何帮助,将不胜感激..