oracle ORA-01722: 简单查询的无效号码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21810148/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORA-01722: invalid number for a simple query
提问by Sasa
I noticed the same topics here but I just couldn't find the answer because of my noob skill in databases, I tried a couple of answers but didn't work, apologies.
我在这里注意到了相同的主题,但由于我在数据库方面的菜鸟技能,我找不到答案,我尝试了几个答案但没有奏效,抱歉。
I have 5 tables and triggers for each of them if the user INSERT, UPDATE, DELETE
如果用户 INSERT、UPDATE、DELETE,我有 5 个表和触发器
After I inserted the data into TRAFFIC, (date (varchar30), input_quant (varchar30), output_quant (varchar30), status (varchar30) )
在我将数据插入后 TRAFFIC, (date (varchar30), input_quant (varchar30), output_quant (varchar30), status (varchar30) )
I've tried a simple query
我试过一个简单的查询
select sum (input_quant)status from traffic;
But the error pops out:
但错误弹出:
ORA-01722: invalid number
01722. 00000 - "invalid number"
*Cause:
*Action:
Is it because of the type (VARCHAR
)?
是因为类型 ( VARCHAR
) 吗?
In the table TRAFFIC and SUPPLY I had to DISABLE the FKs so that I can insert the data, but now that I have inserted them, I can't ENABLE them (parent key not found). I don't think this has something to do with "INVALID NUMBER" error. But I'm still confused. What should I do?
在表 TRAFFIC 和 SUPPLY 中,我必须禁用 FK 以便我可以插入数据,但是现在我已经插入了它们,我无法启用它们(未找到父键)。我不认为这与“无效号码”错误有关。但我还是很困惑。我该怎么办?
回答by dtam
Try count() instead of sum(), sum is add number value for each of the input_quant values. count() is return number count of returned records.
尝试 count() 而不是 sum(),sum 是为每个 input_quant 值添加数值。count() 是返回记录的返回数计数。
Sum() works when the datatype is numeric
Sum() 在数据类型为数字时有效