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

Поиск
Список
Период
Сортировка
От bryan@flyingiranch.com
Тема Re: Stored procedure - change columns in a table that is being updated / inserted on?
Дата
Msg-id H00000660001d07b.1047165077.mule.flyingiranch.com@MHS
обсуждение исходный текст
Ответ на Stored procedure - change columns in a table that is being updated / inserted on?  (bryan@flyingiranch.com)
Список 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


Вложения

В списке pgsql-novice по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Stored procedure - change columns in a table that is being updated / inserted on?
Следующее
От: bryan@flyingiranch.com
Дата:
Сообщение: Re: Stored procedure - change columns in a table that is being updated / inserted on?