"Foster, Stephen" <stephenlfoster@xxxxxxxxxxx> writes: > WHILE (--Lost on variable name for end of query; EmptyQueryResponse <> > 0? --) > BEGIN > IF LastName = fname THEN > DELETE FROM MailingList WHERE id = id; > END IF; > LastName := fname; > FETCH NEXT FROM NewListCursor INTO fname, id; > END; > CLOSE NewListCursor; > $BODY$ > LANGUAGE 'sql' VOLATILE; You can't do any looping or other control structures in an SQL function. Use PL/pgSQL instead. -Doug