Re: Stored procedure - change columns in a table that is being updated / inserted on? - Mailing list pgsql-novice

From bryan@flyingiranch.com
Subject Re: Stored procedure - change columns in a table that is being updated / inserted on?
Date
Msg-id H00000660001d07b.1047165077.mule.flyingiranch.com@MHS
Whole thread Raw
In response to Stored procedure - change columns in a table that is being updated / inserted on?  (bryan@flyingiranch.com)
List pgsql-novice
> This sure seems like the hard way to do it.  If you really want
> tbluserhealthcalculated to be separate from the underlying table,
> why don't you make it a view?
>
> CREATE VIEW tbluserhealthcalculated AS
> SELECT *, (userWeight / (userHeight * userHeight)) AS bmi
> FROM tbluserhealthbasic;

Excellent idea - thanks. I _am_ a novice, so that advice really gives me
some insight.

>
> On the other hand, if you'd rather there were only one table, you
> should be fixing the bmi value in a BEFORE trigger not an
> AFTER trigger.

Also good advice - I didn't really understand the purpose of BEFORE, but
now I undestand that it preps the values before they are committed to
the table.

Thanks again,

Bryan


Attachment

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Stored procedure - change columns in a table that is being updated / inserted on?
Next
From: bryan@flyingiranch.com
Date:
Subject: Re: Stored procedure - change columns in a table that is being updated / inserted on?