Aim : To update the column tgt_tbl_count of recon_count1 table with count of each row of tgt_tbl Error : SQL Error [42601]: ERROR: syntax error at or near "$1".Where: SQL statement in PL/PgSQL function "sp_count_recon_refresh" near line 7
It is unable to resolve the f.tgt_tbl where count(*) is written. I tried by manually passing the f.tgt_tbl name and it is working. Can anyone please help!
create or replace procedure ca_adhoc_view.sp_count_recon_refresh()
language plpgsql as
$$
declare
f record;
res bigint;
BEGIN
for f in select tgt_tbl from ca_adhoc_view.recon_count1
LOOP
update ca_adhoc_view.recon_count1 set tgt_tbl_count = (select count(*) from f.tgt_tbl);
end loop;
END;
$$;