Oracle clob over dblink 使用不同的字符集
场景如下:
Oracle A:字符集 WE8ISO8859P1
Oracle B:字符集 WE8MSWIN1252
Oracle A <- dblink -> Oracle B
我无法直接访问 Oracle B,防火墙问题:(
我必须从 OracleB 获取一些二进制文件,这些文件位于 CLOB 类型的列中(不要问我为什么不能更改为 BLOB)。
我使用“选择插入”将文件从 B 获取到 A,然后使用找到的 clob_to_blob 函数将它们转换为二进制文件。 dbforums.com/oracle/1624851-clob-blob.html#post6313513" rel="nofollow noreferrer">此处。
我收到一些损坏的文件,我相信这是因为 Oracle 通过以下方式自动将 WE8MSWIN1252 转换为 WE8ISO8859P1 dblink (嗯,该列是 CLOB,所以它是文本,对吧?)。
无法以任何方式更改数据库字符集,
有什么解决方法吗?
我
Here is the scenario:
Oracle A: charset WE8ISO8859P1
Oracle B: charset WE8MSWIN1252
Oracle A <- dblink -> Oracle B
I can't access Oracle B directly, firewall issues :(
I have to get some binary files from OracleB and these files are in a column of type CLOB (don't ask me why and I can't change to BLOB).
I'm using a "select insert" to get the files from B to A and them converting them to binary using clob_to_blob function found here.
I'm getting some corrupted files and I believe it's because Oracle is converting WE8MSWIN1252 to WE8ISO8859P1 automatically over the dblink (well, the column is CLOB so it's text, right?).
I can't change the databases charsets in any way.
Is there any workaround for this?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否尝试过使用 DBMS_LOB.CONVERTTOBLOB@remote(....)
但您可能想要获取远程 CLOB 的某种校验和,以查看它们在从任何原始外部源插入/更新时是否进行字符集转换。也就是说,如果插入完成时客户端字符集与数据库字符集不同,则在执行选择之前问题可能已经发生。
编辑添加。
我能想到的最接近的方法需要链接另一端的一些对象。
首先是在远程端进行转换的函数。
其次是呈现数据“BLOB”视图的视图。
这使用了一个虚拟表(基于 v$sql,因为它是我能找到的第一个 CLOB)。我没有理由认为您不能简单地将 CLOB 作为参数传递给函数。
然后,从本地数据库中执行
Have you tried to use DBMS_LOB.CONVERTTOBLOB@remote(....)
But you probably want to get some sort of checksum of the remote CLOB to see whether they are getting a characterset conversion when they are inserted/updated from whatever original external source. That is, if the client characterset, when the insert is done, is different from the database characterset, the problem may have already occurred before you do your select.
Edited to add.
The closest I can come up with requires some objects on the other end of the link.
Firstly a function that does the conversion at the remote end.
Secondly a view that presents a 'BLOB' view of the data.
This uses a dummy table (based of v$sql as it was the first CLOB I could find). No reason I can see that you can't simply pass the CLOB as a parameter to the function.
Then, from the local database, do a
我最好的建议是不要使用数据库链接,而是这样做:
My best suggestion would be not to use the DB link but instead do this:
一个完全不同的选择。
创建与B具有相同字符集的数据库C。将数据从B拉到C(不进行任何转换),然后您可以在将数据移动到A之前在C中进行操作。
A totally different alternative.
Create database C with the same characterset as B. Pull the data from B to C (without any conversion), then you can do you manipulation in C before moving the data to A.