locked
SELECT FOR UPDATE Hangs??? RRS feed

  • Question

  • User-1104215994 posted

    Hi,

    I am trying to get the current Index from Oracle 10g. But when it comes to the SELECT FOR UPDATE command it hangs!!!

    How can I fix this?

    best Regards.

    Code sample:

    Dim connectionString As String = _
           "SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=***)(PORT=***))
    (CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=***)));uid=**;pwd=*;"
            Dim connectionString1 As String = _        "SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=***)(PORT=***))
    (CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=***)));uid=**;pwd=*;"
            Dim maxIndex As Long = Nothing         Dim connOra As New Data.OracleClient.OracleConnection(connectionString)         Dim connOra1 As New Data.OracleClient.OracleConnection(connectionString)         Dim myReader As OracleDataReader = Nothing         Try             'Query Available Index ********* HERE IS THE PROBLEM             Dim comm As New Data.OracleClient.OracleCommand("SELECT TO_NUMBER (NVL (a.cur_val, 0)) + 1
    FROM schema.APP_PARMS a WHERE UPPER(a.parm_nm) = 'ID' FOR UPDATE"
    , connOra)             connOra.Open()             myReader = comm.ExecuteReader()             'Check if Query Returns value             If myReader.HasRows Then                 While myReader.Read()                     If Not myReader(0) Is DBNull.Value Then                         maxIndex = myReader(0)                         Dim comm1 As New Data.OracleClient.OracleCommand("UPDATE schema.APP_PARMS a
    SET a.cur_val = :requestID WHERE UPPER(a.parm_nm) = 'ID'"
    , connOra1)                         comm1.Parameters.Add(New OracleParameter(":requestID", maxIndex))                         'comm1.Parameters.Add("requestID", OracleType.Int32).Value = maxIndex                         connOra1.Open()                         comm1.ExecuteNonQuery()                         'Close Connection                         connOra1.Close()                     End If                 End While             End If             'Close Connection             connOra.Close()             If (Not (myReader) Is NothingThen                 myReader.Close()             End If                     Catch ex As Exception             Dim err As String = ex.Message         End Try
    Thursday, August 4, 2011 6:08 AM

Answers

  • User-1104215994 posted

    No need to update the INdex anymore, company changed the field to sequence!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 9, 2011 2:13 PM

All replies

  • User-1104215994 posted

    May due to OracleDataReader

    I changed it to the following but still the same...

    Dim OraSelectAdapter As New OracleDataAdapter
                OraSelectAdapter.SelectCommand = comm
                Dim ds As New DataSet
     
                connOra.Open()
                OraSelectAdapter.Fill(ds) ---> now halts here *****************

    Thursday, August 4, 2011 6:29 AM
  • User-1104215994 posted

    No need to update the INdex anymore, company changed the field to sequence!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 9, 2011 2:13 PM