SQLPlus 在插入时删除 clob 字段中的尾随空格
我正在使用 SQL Plus 11.1.0.6.0 运行一个脚本,该脚本执行向 Oracle 10g 数据库的批量插入。 问题是,当将一些代码字符串插入到包含一些带有尾随空格的行的 clob 字段中时,例如:
....public void myMethod().... --trailing space here
....{
........int myVar = 1;
........ -- empty line with trailing spaces
........myVar+=1
....}
插入表中的字符串会丢失空行中的那些空尾随空格,并变成:
....public void myMethod() --trailing space is lost
....{
........int myVar = 1;
-- empty line without trailing spaces
........myVar+=1
....}
我注意到的 有用的数据,这是非常令人沮丧的,因为它导致数据与原始数据不同并且无法通过一些测试。
我能找到的只是 SET TRIMSPOOL/TRIMOUT OFF 这不会改变任何东西,有人有其他想法吗?
I'm using SQL Plus 11.1.0.6.0 to run a script that performs batch inserts into an Oracle 10g db.
The problem i noticed is when inserting some code string into a clob field that has some lines with trailing spaces such as:
....public void myMethod().... --trailing space here
....{
........int myVar = 1;
........ -- empty line with trailing spaces
........myVar+=1
....}
The string that gets inserted in the table looses those empty trailing spaces in the empty lines and becomes:
....public void myMethod() --trailing space is lost
....{
........int myVar = 1;
-- empty line without trailing spaces
........myVar+=1
....}
Although it makes no difference to the useful data, this is quite frustrating because it's causing the data to differ from the original and fails some tests.
All i could find was SET TRIMSPOOL/TRIMOUT OFF which doesn't change anything, does anyone have some other ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果不发布您的脚本,很难确定,但您可能不应该将文本字符串直接插入到 SQLPlus 中的 CLOB 中。如果您要使用从文件中提取文本并从 SQLPlus 调用 PL/SQL 的 PL/SQL 过程,它应该保留所有格式。
但这可能是一个万能的 PITA。但 O'Reilly PL/SQL 文本中对此有详细记录。
Without posting your script it's hard to be sure, but you probably shouldn't be inserting text strings directly into a CLOB in SQLPlus. If you were to use a PL/SQL proc that pulled in your text from a file and call the PL/SQL from SQLPlus it should keep all the formatting.
But that may be an almighty PITA. But it's well documented in the O'Reilly PL/SQL texts.
最后我通过这样的黑客解决了它(考虑原始示例):
基本上显式连接所有空格
In the end i solved it by a hack like this (considering original example):
Basically concatenated explicitly all the whitespaces
您可以尝试启用以下参数:
You can try to enable following parameter: