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

From Glenn Schultz
Subject Re: initialize and use variable in query
Date
Msg-id CAE-4=KGf9c4Qhg_gsNcJNb8pewUfTR6vC_Bq_pcm+6sEJhiqXA@mail.gmail.com
Whole thread Raw
In response to initialize and use variable in query  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
Thanks! 

On Sat, Dec 29, 2018 at 10:06 AM David G. Johnston <david.g.johnston@gmail.com> wrote:
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: initialize and use variable in query
Next
From: Glenn Schultz
Date:
Subject: Recursive CTE