initialize and use variable in query - Mailing list pgsql-general

From David G. Johnston
Subject initialize and use variable in query
Date
Msg-id CAKFQuwanKATk5AUrU5HHeZ2kiWM=Znk3mZBQapF_y2x2BHZ3cg@mail.gmail.com
Whole thread Raw
In response to Re: initialize and use variable in query  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: initialize and use variable in query  (Glenn Schultz <glenn@bondlab.io>)
List pgsql-general
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.

David J.

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: initialize and use variable in query
Next
From: Glenn Schultz
Date:
Subject: Re: initialize and use variable in query