1

我在我的 vb.net 应用程序中收到 ORA-01036:非法变量名称/编号错误请看一下并帮助我。

提前致谢。

Dim sSQL As String

    sSQL = "INSERT INTO PSLSC_PSL_NOMINATION ( NOMINATION_ID, NOM_TYPE, PROPOSED_STATUS, COMMODITY_TEAM, COMMODITY_DESC, COMMODITY_CODE, PARENT_ID, SUPPLIER_ID, SUPPLIER_NAME, ADDRESS, COUNTRY, TELEPHONE, CONTACT, WEBSITE, EMAIL, SPEND, TECHSOURCE_SCORE, ESAC_SCORE, PAYMENT_TERMS, MSA_CONTRACT, BUSA_CONTRACT, LEAN_CHAMPION, LEAN_CHAMPION_NAME, QUALITY, ON_TIME_DELIVERY, SUPPORTS_ESOURCING, COMPLIANCE_REQUIREMENT, FLEXIBILITY, CAP_MEET_DELIVERY_FREQ, NOMINATING_BUSINESS_UNIT, NOMINATING_REGION, OWNER, NOMINATED_DATE, COMMENTS, SENDER, SENDER_EMAIL )"
    sSQL = sSQL & " VALUES ( :NOMINATION_ID,:NOM_TYPE,:PROPOSED_STATUS,:COMMODITY_TEAM,:COMMODITY_DESC,:COMMODITY_CODE,:PARENT_ID,:SUPPLIER_ID,:SUPPLIER_NAME,:ADDRESS,:COUNTRY,:TELEPHONE,:CONTACT,:WEBSITE,:EMAIL,:SPEND,:TECHSOURCE_SCORE,:ESAC_SCORE,:PAYMENT_TERMS,:MSA_CONTRACT,:BUSA_CONTRACT,:LEAN_CHAMPION,:LEAN_CHAMPION_NAME,:QUALITY,:ON_TIME_DELIVERY,:SUPPORTS_ESOURCING,:COMPLIANCE_REQUIREMENT,:FLEXIBILITY,:CAP_MEET_DELIVERY_FREQ,:NOMINATING_BUSINESS_UNIT,:NOMINATING_REGION,:OWNER,:NOMINATED_DATE,:COMMENTS,:SENDER,:SENDER_EMAIL )"

    Dim obj_id As Decimal
    obj_id = getNewSRM_OBJ_ID(cn_SRM)

    Dim cn As OracleConnection = New OracleConnection(cn_proc)
    Dim cmd As OracleCommand = New OracleCommand(sSQL, cn)
    cmd.Parameters.Add(":NOMINATION_ID", obj_id)
    cmd.Parameters.Add(":NOM_TYPE", row.NOM_TYPE)
    cmd.Parameters.Add(":PROPOSED_STATUS", row.PROPOSED_STATUS)
    cmd.Parameters.Add(":COMMODITY_TEAM", row.COMMODITY_TEAM)
    cmd.Parameters.Add(":COMMODITY_DESC", row.COMMODITY_DESC)
    cmd.Parameters.Add(":COMMODITY_CODE", row.COMMODITY_CODE)
    cmd.Parameters.Add(":PARENT_ID", row.PARENT_ID)
    cmd.Parameters.Add(":SUPPLIER_ID", row.SUPPLIER_ID)
    cmd.Parameters.Add(":SUPPLIER_NAME", row.SUPPLIER_NAME)
    cmd.Parameters.Add(":ADDRESS", row.ADDRESS)
    cmd.Parameters.Add(":COUNTRY", row.COUNTRY)
    cmd.Parameters.Add(":PHONE", row.PHONE)
    cmd.Parameters.Add(":CONTACT", row.CONTACT)
    cmd.Parameters.Add(":WEBSITE", row.WEBSITE)
    cmd.Parameters.Add(":EMAIL", row.EMAIL)
    cmd.Parameters.Add(":SPEND", row.SPEND)
    cmd.Parameters.Add(":TECHSOURCE_SCORE", row.TECHSOURCE_SCORE)
    cmd.Parameters.Add(":ESAC_SCORE", row.ESAC_SCORE)
    cmd.Parameters.Add(":PAYMENT_TERMS", row.PAYMENT_TERMS)
    cmd.Parameters.Add(":MSA_CONTRACT", row.MSA_CONTRACT)
    cmd.Parameters.Add(":BUSA_CONTRACT", row.BUSA_CONTRACT)
    cmd.Parameters.Add(":LEAN_CHAMPION", row.LEAN_CHAMPION)
    If Not row.IsLEAN_CHAMPION_NAMENull Then
        cmd.Parameters.Add(":LEAN_CHAMPION_NAME", row.LEAN_CHAMPION_NAME)
    Else
        cmd.Parameters.Add(":LEAN_CHAMPION_NAME", System.DBNull.Value)
    End If
    cmd.Parameters.Add(":QUALITY", row.QUALITY)
    cmd.Parameters.Add(":ON_TIME_DELIVERY", row.ON_TIME_DELIVERY)
    cmd.Parameters.Add(":SUPPORTS_ESOURCING", row.SUPPORTS_ESOURCING)
    cmd.Parameters.Add(":COMPLIANCE_REQUIREMENT", row.COMPLIANCE_REQUIREMENT)
    cmd.Parameters.Add(":FLEXIBILITY", row.FLEXIBILITY)
    cmd.Parameters.Add(":CAP_MEET_DELIVERY_FREQ", row.CAP_MEET_DELIVERY_FREQ)
    cmd.Parameters.Add(":NOMINATING_BUSINESS_UNIT", row.NOMINATING_BUSINESS_UNIT)
    cmd.Parameters.Add(":NOMINATING_REGION", row.NOMINATING_REGION)
    cmd.Parameters.Add(":OWNER", row.OWNER)
    cmd.Parameters.Add(":NOMINATED_DATE", row.NOMINATED_DATE)
    cmd.Parameters.Add(":COMMENTS", row.COMMENTS)
    cmd.Parameters.Add(":SENDER", row.SENDER)
    cmd.Parameters.Add(":SENDER_EMAIL", row.SENDER_EMAIL)


    Try
        cn.Open()
        cmd.CommandType = CommandType.Text
        cmd.ExecuteNonQuery()
    Catch ex As Exception
        LOG_ERROR(ex.Message, sSQL, cn.ConnectionString, ex.Source)
    End Try
4

1 回答 1

1

当您从 SQL 中省略绑定变量引用但为它创建参数时,您也可能会收到此错误。问我怎么知道的。

从上面获取的示例可能会重现它(注意“PROPOSED_STATUS”不在 SQL 中,但作为参数添加:

sSQL = "INSERT INTO PSLSC_PSL_NOMINATION ( NOMINATION_ID, NOM_TYPE ) VALUES ( :NOMINATION_ID,:NOM_TYPE )"

Dim obj_id As Decimal = getNewSRM_OBJ_ID(cn_SRM)

Dim cn As OracleConnection = New OracleConnection(cn_proc)
Dim cmd As OracleCommand = New OracleCommand(sSQL, cn)
cmd.Parameters.Add(":NOMINATION_ID", obj_id)
cmd.Parameters.Add(":NOM_TYPE", row.NOM_TYPE)
cmd.Parameters.Add(":PROPOSED_STATUS", row.PROPOSED_STATUS)

Try
    cn.Open()
    cmd.CommandType = CommandType.Text
    cmd.ExecuteNonQuery()
Catch ex As Exception
    LOG_ERROR(ex.Message, sSQL, cn.ConnectionString, ex.Source)
End Try
于 2019-01-30T01:22:37.820 回答