简体   繁体   English

来自C#的Oracle无效数字错误

[英]Oracle Invalid number error from C#

I run the below code in my C# .Net application, but I keep getting error ORA-01722: invalid number . 我在C#.Net应用程序中运行以下代码,但我不断收到错误ORA-01722:无效编号 When running the same SQL directly in PL/SQL Developer it does exactly what I ask it to without complaining. 当直接在PL / SQL Developer中运行相同的SQL时,它完全可以执行我要求的操作而不会抱怨。

What could be causing this? 是什么原因造成的?

OracleCommand command = connection.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = "insert into my_table ( select i.*, null from my_view i where i.usr_id is not null )";
command.ExecuteNonQuery();

Note: I am using Oracle.DataAccess.Client 注意:我正在使用Oracle.DataAccess.Client

I found the problem. 我发现了问题。 One of the number columns in the view used a comma (,) as a decimal seperator, while the table expected a point (.). 视图中的数字列之一使用逗号(,)作为小数点分隔符,而表则期望使用点(。)。

Thanks for the help people. 感谢您的帮助。 :) :)

I'm not sure whether this could cause different behaviour between Developer and your client, but you're making an assumption that the column order is the same in the view and the table. 我不确定这是否会导致Developer和您的客户端之间发生不同的行为,但是您假设视图和表中的列顺序相同。 It's possible , though unlikely, that it's trying to insert char data from a column in the view into a number field in the table just from sequencing them differently. 尽管不太可能 ,但是它可能试图将视图中的列中的char数据插入表中的number字段中,而只是将它们的排序方式不同。 Try specifying the column names in both the insert and select and see if it helps. 尝试在插入和选择中都指定列名,看看是否有帮助。 I also wondered if there was a date format mismatch but I don't see how that would cause a problem within one statement. 我还想知道是否存在日期格式不匹配,但我看不出这将如何在一条语句中引起问题。 If this is a simplified version, does the real one have any parameters? 如果这是简化版本,那么实际版本是否有任何参数?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM