ORA-01722:C#中INSERT上的编号无效-Oracle 11g

我有这张Oracle 11g表

CREATE TABLE "DBNAME"."CANDIDATES" 
(
    "ID" NUMBER(24,0), 
    "USRINS" VARCHAR2(30 CHAR), 
    "DATINS" DATE, 
    "USRUPD" VARCHAR2(30 CHAR), 
    "DATUPD" DATE, 
    "EXM_ID" NUMBER(24,0), 
    "TYPE" NUMBER(3,0), 
    "PSN_ID" NUMBER(24,0), 
    "KOD" NUMBER(20,0), 
    "STATUS" NUMBER(20,0), 
    "PRICINA" VARCHAR2(200 CHAR)
)

现在我在C#中有此命令

string insertIntoCandidates = "INSERT INTO CANDIDATES " &
  "(USRINS, DATINS, PSN_ID, KOD, STATUS, PRICINA) " &
  values ("
                     + ":usrins, "
                     + ":datins, "
                     + ":psn_id, "
                     + ":kod, "
                     + ":status, "
                     + ":pricina"
                     + ") ";

command.Parameters.Add(":usrins", null);
command.Parameters.Add(":datins", DateTime.Now);
command.Parameters.Add(":psn_id", getPsnIDByEMBG(result.embg));
command.Parameters.Add(":kod", result.kod_kandidat);
if (result.status)
{
    command.Parameters.Add(":status", 1);
}
else
{
    command.Parameters.Add(":status", 0);
}

command.Parameters.Add(":pricina", result.pricina);

int res = command.ExecuteNonQuery();

我没有为其插入值的列可以获取空值.
执行最后一行后,出现异常ORA-01722:无效的数字.我试图寻找答案,但是没有任何运气.你能帮我吗?谢谢

解决方法:

试图将字符串转换为数字时出现ORA-01722(“无效数字”)错误,并且该字符串无法转换为有效数字.因此,请检查参数以获取正确的数据类型.

还请参见:

C# parameterized queries for Oracle – serious & dangerous bug!

Why am I getting an ORA-01722 (invalid number)?

上一篇:oracle数据库,如何通过plsql往表中插入数据?


下一篇:PLSQL图形界面设置oracle的JOBS