1

Dont know what I am doing wrong. can anyone help. Not even sure for which parameter I am getting this error.

var sql = @"
        UPDATE Test_Tem_Table  SET
            SOFTCLSD_IND = :SOFTCLSD_IND
          , SOFTCLSD_DT = :SOFTCLSD_DT
          , SOFTCLSD_BY = :SOFTCLSD_BY
          , SOFTCLSD_COMMENT = :SOFTCLSD_COMMENT
          , SOFTCLSD_LASTUPDT_BY = :SOFTCLSD_LASTUPDT_BY
          , SOFTCLSD_LASTUPDT_DT = :SOFTCLSD_LASTUPDT_DT 
        WHERE PREFIX_CB_ELIG_ID = :PREFIX_CB_ELIG_ID";

        var param = AdoTemplate.CreateDbParameters();
        param.Add("SOFTCLSD_IND", System.Data.OracleClient.OracleType.Char).Value = DBUtils.ConvertBoolToYN(currentSoftClose.IsSoftClosed);
        param.Add("SOFTCLSD_DT", System.Data.OracleClient.OracleType.DateTime).Value = ((DateTime)currentSoftClose.SoftClosedDate).Date;
        param.Add("SOFTCLSD_BY", System.Data.OracleClient.OracleType.VarChar).Value = currentSoftClose.SoftClosedBy;
        param.Add("SOFTCLSD_COMMENT", System.Data.OracleClient.OracleType.VarChar).Value = currentSoftClose.Comments;
        param.Add("SOFTCLSD_LASTUPDT_BY", System.Data.OracleClient.OracleType.VarChar).Value = currentSoftClose.SoftClosedLastUpdatedBy;
        param.Add("SOFTCLSD_LASTUPDT_DT", System.Data.OracleClient.OracleType.DateTime).Value = currentSoftClose.SoftClosedLastUpdatedDate == null ? (DateTime?)null : ((DateTime)currentSoftClose.SoftClosedLastUpdatedDate).Date;
        param.Add("PREFIX_CB_ELIG_ID", System.Data.OracleClient.OracleType.Number).Value = currentSoftClose.Id;

        return AdoTemplate.ExecuteNonQuery(CommandType.Text, sql, param);
Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
Tronics
  • 1,438
  • 4
  • 22
  • 33
  • Is the above code verbatim; you haven’t perhaps elided any comments in the SQL? https://stackoverflow.com/questions/7493028/ora-01008-not-all-variables-bound-they-are-bound – sellotape Mar 29 '19 at 19:11
  • I am getting this error when I am passing null to SOFTCLSD_LASTUPDT_DT parameter. – Tronics Mar 29 '19 at 19:32
  • Try a DBNull instead when it’s null. – sellotape Mar 29 '19 at 19:35
  • currentSoftClose.SoftClosedLastUpdatedDate == null ? DBNull.Value : ((DateTime)currentSoftClose.SoftClosedLastUpdatedDate).Date; throwing error ni implict conversion between system.DBNull and System.DateTime – Tronics Mar 29 '19 at 19:42
  • I’m out of ideas. You could bodge it if you’re under time pressure by switching on the nullness of the date and using different SQL and parameters for each, but it’s not a very satisfactory solution. – sellotape Mar 29 '19 at 20:16
  • this one worked currentSoftClose.SoftClosedLastUpdatedDate ?? (object)DBNull.Value; – Tronics Mar 29 '19 at 20:16

0 Answers0