Re: GENERATE AS - Mailing list pgsql-admin

From Ilya Kosmodemiansky
Subject Re: GENERATE AS
Date
Msg-id D598E4B1-1B40-4B55-89A2-9296CDD2985D@dataegret.com
Whole thread Raw
In response to GENERATE AS  ("Wetmore, Matthew (CTR)" <Matthew.Wetmore@express-scripts.com>)
Responses Re: GENERATE AS
List pgsql-admin
Hi Matthew,

On 22. Jun 2023, at 22:00, Wetmore, Matthew (CTR) <Matthew.Wetmore@express-scripts.com> wrote:

4. ALTER TABLE auto_auth.matt

               ADD column matt_hour INT  GENERATED ALWAYS AS (date_part('hour', current_timestamp)::INT - date_part('hour', matt_time)::INT) stored       

              

               ERROR:  generation expression is not immutable

SQL state: 42P17


You can use only immutable functions to generate columns. Timestamp with time zone as an argument makes function not immutable because timezone could be set locally and  results could differ depending on timezone 

best regards,
Ilya

 

 

@font-face { font-family: "Cambria Math"; } @font-face { font-family: Calibri; } p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0in 0in 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; } a:link, span.MsoHyperlink { color: rgb(5, 99, 193); text-decoration: underline; } a:visited, span.MsoHyperlinkFollowed { color: rgb(149, 79, 114); text-decoration: underline; } span.EmailStyle17 { font-family: Calibri, sans-serif; color: windowtext; } .MsoChpDefault { font-family: Calibri, sans-serif; } @page WordSection1 { size: 8.5in 11in; margin: 1in; } div.WordSection1 { page: WordSection1; }

pgsql-admin by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: GENERATE AS
Next
From: "David G. Johnston"
Date:
Subject: Re: GENERATE AS