In Sybase SQL Anywhere and PostgreSQL, you can use the FOR statement to execute the specified statements for each row in a cursor.
Sybase SQL Anywhere:
CREATE PROCEDURE show_colors() BEGIN FOR rec AS cur CURSOR FOR SELECT name FROM colors DO MESSAGE 'Color: ' || name TO CLIENT; END FOR; END GO
PostgreSQL:
CREATE OR REPLACE PROCEDURE show_colors() AS $$ DECLARE rec RECORD; BEGIN FOR rec IN SELECT name FROM colors LOOP RAISE NOTICE '%', CONCAT('Color: ' , rec.name); END LOOP; END; $$ LANGUAGE plpgsql;
For more information, see Sybase SQL Anywhere to PostgreSQL Migration.