우리 소프트웨어에 문제가있어서 문제를 해결하기 위해 업그레이드 설치를 위해 업그레이드 프로세스의 일부로 실행할 저장 프로 시저를 작성해야합니다. 이 저장 프로시 저는 특정 조건과 일치하는 특정 테이블의 모든 행을 찾아 해당 행을 갱신해야합니다. 내부적 인 이유로 업데이트는 데이터를 삽입하고 업데이트하기 위해 특별히 작성한 저장 프로 시저를 통해 수행해야합니다. 여기 이 PostgreSQL 9.1 저장 프로 시저는 어떻게 수정합니까?
내가이 문제를 해결하기 위해 작성한 저장 프로 시저입니다 :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;
이 저장 프로 시저의 벌금을,하지만 난 그것을 실행할 때, 내가 얻을 :
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
가 어떻게이 문제를 해결합니까 발행물? 저장 프로 시저를 올바르게 호출하고 있다고 생각합니다. 난 정말이 저장 프로 시저의 문제가 뭔지 모르겠다. 그것은 바로 거기라고
감사
토니
오류 메시지의 조언을 따르는 것이 어떨까요? –