Im building a stored procedure in amazon redshift. This is an example of what im trying to do.
CREATE OR REPLACE PROCEDURE test_sp1()
LANGUAGE plpgsql
AS $$
DECLARE v_test RECORD;
BEGIN
FOR v_test IN select * from pg_user
LOOP
RAISE INFO 'before loop';
CONTINUE;
RAISE INFO 'after loop';
END LOOP;
END;
$$;
CALL test_sp1();
This piece of code gives me an exception "[42601][500310] Amazon Invalid operation: CONTINUE cannot be used outside a loop".
Why can i not use continue in this loop?
LOOP
within aFOR
?CONTINUE
would be used to exit from a nested loop. Doing a Continue in a single loop just means the loop would run again, which doesn't seem to make sense. What are you actually wanting to accomplish? – John Rotenstein