Re: initialize and use variable in query

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

Thanks!

On Sat, Dec 29, 2018 at 10:06 AM David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> 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

Browse pgsql-general by date

  From Date Subject
Next Message Glenn Schultz 2018-12-29 18:34:31 Recursive CTE
Previous Message David G. Johnston 2018-12-29 16:06:43 initialize and use variable in query