Hi,
I'm new to postgresql. I'm trying to get a function that will loops through a cursor, and update every row. I have tried various permutations of the below, but am getting syntax errors. Can anyone suggest what is wrong with the given example?
DECLARE
curs1 CURSOR
FOR
SELECT *
FROM myTable ;
BEGIN
FOR i IN curs1 LOOP
UPDATE myTable
SET field3 =
i.field1 ||
i.field2
WHERE CURRENT OF curs1;
END LOOP
This gives me the error:
ERROR: syntax error at or near "$1" at character 3
QUERY: $1
Any ideas?
END;
I'm new to postgresql. I'm trying to get a function that will loops through a cursor, and update every row. I have tried various permutations of the below, but am getting syntax errors. Can anyone suggest what is wrong with the given example?
DECLARE
curs1 CURSOR
FOR
SELECT *
FROM myTable ;
BEGIN
FOR i IN curs1 LOOP
UPDATE myTable
SET field3 =
i.field1 ||
i.field2
WHERE CURRENT OF curs1;
END LOOP
This gives me the error:
ERROR: syntax error at or near "$1" at character 3
QUERY: $1
Any ideas?
END;