Calculated Fields in Postgres?

From: "Jeanna Geier" <jgeier(at)apt-cafm(dot)com>
To: "Pgsql-Jdbc(at)Postgresql(dot)Org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Calculated Fields in Postgres?
Date: 2007-01-02 21:47:50
Message-ID: FBEGJLLJBCOMCDBJHIMEIEEECCAA.jgeier@apt-cafm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello List!

Still trying to learn Postgres... =) I have a question on how/where to
define a calculated field in a table...

Let's say I have a 'Replacement Cost' table with the following fields:

Original Cost
Original Date
Life Expectancy
Life Units

and I want to add a 'Mfg. Replace Date' field, which is a calculated field
with the following formula:

IF ('Life Units' = NAV)
THEN (NAV)
ELSE
( IF ('Life Units' = 'Day(s)'')
THEN (AddDate('Original Date,0,0,'Life Expectancy'))
ELSE
( IF 'Life Units' = 'Month(s)'')
THEN (AddDate('Original Date',0,'Life Expectancy',0))
ELSE
( IF 'Life Units' = 'Year(s)'')
THEN (AddDate('Original Date','Life Expectancy',0.0))
ELSE
(today))))

--------------------------------------------------------

How/where do I define this calculated field?

Any help or guidance that anyone could provide will be greatly appreciated!

If any more information is necessary from my end, please let me know.

Thanks,
-Jeanna

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Andres Olarte 2007-01-02 22:00:51 Re: Calculated Fields in Postgres?
Previous Message Andrew Lazarus 2007-01-02 18:50:53 Re: Help with RULES - Please!