Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-6388

Example WHERE CURRENT OF clause in Reference Guide is nonsense

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 10.11.1.1
    • 10.10.2.0, 10.11.1.1
    • Documentation
    • None
    • Normal

    Description

      The Reference Guide section titled "WHERE CURRENT OF clause" provides some sample code. The code doesn't even compile. It has a number of defects:

      1) Autocommit needs to be turned on.

      2) The cursor name needs to be ALL CAPS in the s.setCursorName() statement.

      3) The ResultSet needs to be created from the statement and can't be created directly from the connection.

      4) The ResultSet needs to be positioned before the UPDATE is run.

      The following cleaned-up code compiles and runs correctly:

      conn.setAutoCommit( false );

      Statement s = conn.createStatement();
      s.setCursorName("AIRLINESRESULTS");
      ResultSet rs = s.executeQuery(
      "SELECT Airline, basic_rate " +
      "FROM Airlines FOR UPDATE OF basic_rate");
      rs.next();
      Statement s2 = conn.createStatement();
      s2.executeUpdate("UPDATE Airlines SET basic_rate = basic_rate " +
      "+ .25 WHERE CURRENT OF AirlinesResults");

      Attachments

        1. rrefsqlj15309.html
          3 kB
          Camilla Haase
        2. rrefsqlj15309.html
          4 kB
          Camilla Haase
        3. DERBY-6388-2.diff
          1 kB
          Camilla Haase
        4. DERBY-6388.diff
          1 kB
          Camilla Haase

        Activity

          People

            chaase3 Camilla Haase
            rhillegas Richard N. Hillegas
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: