On Saturday, December 29, 2018, Ray O'Donnell <ray@rodonnell.ie> wrote:
A couple of things off the top of my head:
Sorry but, no.
(i) I think you need "language plpgsql" (or whatever) after the DO block.
As the docs state plpgsql is the default for a DO block lacking a language specifier.
(ii) That assignment in the DO should probably be:
select max(fctrdt) into startdate from fnmloan;
The original form is perfectly valid plpgsql;
The DO block worked just fine. It’s just that everything it did was discarded at the end of it because nothing that permanently affected the parent SQL session happened.