Re: GENERATE AS - Mailing list pgsql-admin

From David G. Johnston
Subject Re: GENERATE AS
Date
Msg-id CAKFQuwbgETyn7DoEBT3CzhZzwfhUa_Z=AGbhTGqqgn1=Vgsf7A@mail.gmail.com
Whole thread Raw
In response to GENERATE AS  ("Wetmore, Matthew (CTR)" <Matthew.Wetmore@express-scripts.com>)
List pgsql-admin
On Thu, Jun 22, 2023 at 1:00 PM Wetmore, Matthew (CTR) <Matthew.Wetmore@express-scripts.com> wrote:

Hi, I have this issue and now I’m just wasting time. Can you tell me what I’m doing wrong?


Like the error message says - you are trying to use a generated expression when one of the inputs is volatile (or, is not immutable).

It makes no sense to store "hours elapsed" when the concept of current time (an ever changing concept) is being used in the formula.  Create a view with you expression then the view can always provide an accurate value for elapsed time as of when the query is run.

David J.

pgsql-admin by date:

Previous
From: "Wetmore, Matthew (CTR)"
Date:
Subject: GENERATE AS
Next
From: Ilya Kosmodemiansky
Date:
Subject: Re: GENERATE AS