Does FOR LOOP work on SELECT? The following simple function looks good to
me but does not compile because of "missing .. at end of SQL expression".
CREATE FUNCTION get_all_diffs()
RETURNS FLOAT AS '
DECLARE
i INTEGER := 0;
sym_diff FLOAT := 0.0;
BEGIN
FOR row IN SELECT * FROM "tblTrades" LOOP
i := i+1;
END LOOP;
RETURN sym_diff;
END;'
LANGUAGE 'plpgsql'
;
SELECT get_all_diffs();