2

i would like to use oracle parameters to insert data into the oracle db. i do the same in with sql server and it works fine. But with oracle i always get the ORA-00936: missing expression exception on the oCom.ExecuteNonQuery.

thanks for answers.. here is my vb.net code.

Using connOMS = New OracleConnection(connectionStringOMS)
Try
    connOMS.Open()

    Dim cmdstr As String = "INSERT INTO ARCHIVE_FEEDBACK(STATUS) VALUES(@STATUS)"

    Using Ocom As OracleCommand = New OracleCommand(cmdstr, connOMS)
        Dim p As OracleParameter
        p = New OracleParameter()
        p.Direction = ParameterDirection.InputOutput
        p.OracleDbType = OracleDbType.Varchar2
        p.ParameterName = "@STATUS"
        p.Value = "A"
        Ocom.Parameters.Add(p)

        Dim iRet As Integer = Ocom.ExecuteNonQuery
        If iRet > 0 Then
            Return True
        Else
            Return False
        End If
    End Using

    Catch ex As ApplicationException
        '...
    Catch orex As OracleException
        '...
    Finally

End Try

End Using

1 Answer 1

3

For Oracle, you need to use a colon (:) rather than the "at" sign (@) to indicate a parameter:

Dim cmdstr As String = "INSERT INTO ARCHIVE_FEEDBACK(STATUS) VALUES(:STATUS)"

and later on...

p.ParameterName = ":STATUS"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.