Below is my stored procedure which I am trying to create. I am converting the table data into json and loop the JSON which I have created. But I am facing issue while doing so.
CREATE OR REPLACE FUNCTION file_compare()
RETURNS text
LANGUAGE 'plpgsql'
COST 100
VOLATILE
AS $BODY$
declare
fpo_data jsonb;
loopupto INTEGER := 0;
begin
select json_agg(("fpdata"))::jsonb
FROM (
SELECT "fo_data" as fpdata
from fpo
limit 100
) t INTO "fpo_data";
FOR i IN "fpo_data"
LOOP
RAISE NOTICE 'output from space %', i;
END LOOP;
return fpo_data;
end;
$BODY$;
I am getting the below error
ERROR: syntax error at or near ""fpo_data""
LINE 27: FOR i IN "fpo_data"
What is the issue? Please help!!