【问题标题】:Oracle's ODP.Net can't handle newlines .Net newlines? [closed]Oracle 的 ODP.Net 不能处理换行符 .Net 换行符? [关闭]
【发布时间】:2012-11-09 10:33:05
【问题描述】:

对于 .Net 4.0 应用程序,我使用的是 ODP.Net 11 库中的 OracleClient 类。经过一番研究,有些人注意到 ODP.net 库无法处理 Windows 换行符,而只能处理 unix 换行符(无法处理 \r)。当我用空格替换每个 \r 出现时,查询运行正常。

我在这里遗漏了什么还是 Oracle 只是在荒谬?

我收到以下错误:

Message: ORA-06550: line 1, column 6:
PLS-00103: Encountered the symbol "" when expecting one of the following:

   begin case declare exit for goto if loop mod null pragma
   raise return select update while with <an identifier>
   <a double-quoted delimited-identifier> <a bind variable> <<
   close current delete fetch lock insert open rollback
   savepoint set sql execute commit forall merge pipe
The symbol "begin was inserted before "" to continue.
ORA-06550: line 2, column 90:
PLS-00103: Encountered the symbol "" when expecting one of the following:

   begin case declare end exception exit for goto if loop mod
   null pragma raise return select update while with
   <an identifier> <a double-quoted delimited-id

【问题讨论】:

  • 但这只是一个荒谬的oracle事情......我知道解决方法,但只是oracle如何制作库而不支持本机环境设置?对我来说,我知道没有一个设置或旧版本可以工作......

标签: .net sql oracle odp.net


【解决方案1】:

ODP.NET 不支持/r,您必须像这样删除它:

OracleCommand cmd = new OracleCommand();
cmd .CommandType = CommandType.Text;
cmd .CommandText = commandText.Replace("\r", "");

【讨论】:

  • 是的,我想了这么多...但是 .Net 库不支持 windows 换行符不是很疯狂吗?
  • 它可能会由 Java 开发人员开发。 =)
  • Figures... 但主要问题是我们使用的是 OleDbConnection 并用 DbConnection 替换了所有内容。随着这一变化,我们转而使用本机客户端 SQLConnection 和 OracleConnection。查询生成我们使用带有 Append 和 AppendLine 的 StringBuilders 以提高日志记录的可读性。 AppendLine 的缺点是它使用了 OracleClient 没有得到的 Environment.NewLine (\r\n)...我拒绝遍历所有代码并替换 \r,因为恕我直言,这毕竟不是问题...
  • @Ferdy 您可以从 OracleCommand 派生并覆盖 CommandText 属性,因此您无需更改每一段代码。
猜你喜欢
  • 1970-01-01
  • 2014-08-17
  • 2011-12-15
  • 1970-01-01
  • 2014-11-01
  • 2023-02-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多