ORA-00947: not enough values

最后都变了- 提交于 2019-12-12 04:59:41

问题


I get an error "ORA-00947: not enough values") inserting a record and can't see why! It seems to me I have the correct number of parameters:

string sQuery = "insert into EventLog (UserEventLogID, USERID, EVENTSEVERITYID, LOGTIME_TZ, USEREVENTTYPEID, USEREVENTMSG) " +
    "values (0, :USERID, :EVENTSEVERITYID, cast(:LOGTIME_TZ as Timestamp(6) With Time Zone) at time zone '" + oLog.TimeZone + "'), " +
    ":EVENTTYPEID, :EVENTMSG) " +
    " returning USEREVENTLOGID into :EventLogID";

    oraCmd = new OracleCommand();
    oraCmd.BindByName = true;
    oraCmd.Parameters.Add("EVENTSEVERITYID", OracleDbType.Int16, 2, oLog.EventSeverityID, ParameterDirection.Input);
    oraCmd.Parameters.Add("LOGTIME_TZ", OracleDbType.TimeStamp, 6, oLog.EventTimestamp, ParameterDirection.Input);
    oraCmd.Parameters.Add("EVENTTYPEID", OracleDbType.Int16, 4, oLog.EventTypeID, ParameterDirection.Input);
    oraCmd.Parameters.Add("EVENTMSG", OracleDbType.Varchar2, 300, oLog.EventMsg, ParameterDirection.Input);
    oraCmd.Parameters.Add("USERID", OracleDbType.Varchar2, 50, oLog.UserID, ParameterDirection.Input);

    outParam = new OracleParameter("EventLogID", OracleDbType.Decimal);
    outParam.Direction = ParameterDirection.Output;
    oraCmd.Parameters.Add(outParam);

the table has one more column "LGTIME" which is nullable so I did not include it in insert statement.


回答1:


I see an extra ")" . cast(:LOGTIME_TZ as Timestamp(6) With Time Zone) <----- at time zone '" + oLog.TimeZone + "')



来源:https://stackoverflow.com/questions/15098907/ora-00947-not-enough-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!