initialize and use variable in query

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "Ray O'Donnell" <ray(at)rodonnell(dot)ie>
Cc: Glenn Schultz <glenn(at)bondlab(dot)io>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: initialize and use variable in query
Date: 2018-12-29 16:06:43
Message-ID: CAKFQuwanKATk5AUrU5HHeZ2kiWM=Znk3mZBQapF_y2x2BHZ3cg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Saturday, December 29, 2018, Ray O'Donnell <ray(at)rodonnell(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Glenn Schultz 2018-12-29 18:27:25 Re: initialize and use variable in query
Previous Message David G. Johnston 2018-12-29 15:59:32 Re: initialize and use variable in query