title: How do I fix this PostgreSQL 9.1 stored procedure?
body: <p>We have a problem with our software and in order to correct the issue, I have to write a stored procedure that will be run as part of the upgrade process for upgrade installs.  This stored procedure needs to find every row in a particular table that matches certain conditions and update that row.  For internal reasons, the update has to be done through a stored procedure we wrote specifically for inserting and updating data.</p>
  
  <p>Here is the stored procedure I have written to fix this issue:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION FixDataProblem() RETURNS VOID AS $$
  DECLARE
      FixCursor   NO SCROLL CURSOR FOR
          SELECT * FROM MyTable WHERE ProblemColumn IN ( '?', 'PR' );
      RowToUpdate         MyTable%ROWTYPE;
  BEGIN
      -- Open the cursor
      OPEN FixCursor;
  
      -- Start a loop
      LOOP
          -- Fetch the next row from thr cursor
          FETCH FixCursor INTO RowToUpdate;
  
          -- Did we get anything back?
          IF RowToUpdate IS NULL THEN
              -- We didn't. Exit the loop
              EXIT;
          END IF;
  
          -- Call the UpsertMyTable stored procedure to set the ProblemColumn column to NULL
          SELECT CarSystem.UpsertMyTable( RowToUpdate.RowId,
                                 RowToUpdate.ForeignId,
                                 RowToUpdate.CountryId,
                                 NULL,
                                 RowToUpdate.Plate,
                                 RowToUpdate.HashedData,
                                 RowToUpdate.PlateClassId,
                                 RowToUpdate.AlarmClassId,
                                 RowToUpdate.BeginDate,
                                 RowToUpdate.EndDate,
                                 RowToUpdate.ListPriorityId,
                                 RowToUpdate.VehicleTypeId,
                                 RowToUpdate.MakeId,
                                 RowToUpdate.ModelId,
                                 RowToUpdate.Year,
                                 RowToUpdate.ColorId,
                                 RowToUpdate.Notes,
                                 RowToUpdate.OfficerNotes,
                                 NULL,
                                 UUID_GENERATE_V4() );
      END LOOP;
  
      -- Close the cursor
      CLOSE ListDetailsCursor;
  END;
  $$ LANGUAGE plpgsql;
  </code></pre>
  
  <p>This stored procedure fine, but when I run it, I get:</p>
  
  <pre><code>ERROR:  query has no destination for result data
  HINT:  If you want to discard the results of a SELECT, use PERFORM instead.
  CONTEXT:  PL/pgSQL function "fixdataproblem" line 22 at SQL statement
  
  
  ********** Error **********
  
  ERROR: query has no destination for result data
  SQL state: 42601
  Hint: If you want to discard the results of a SELECT, use PERFORM instead.
  Context: PL/pgSQL function "fixdataproblem" line 22 at SQL statement
  </code></pre>
  
  <p>How do I fix this issue?  I believe I am calling the stored procedure correctly.  I really don't know what the issue with this stored procedure is.</p>
  
  <p>Thanks</p>
  
  <p>Tony</p>