Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: column defa...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 5 Topic 3556 of 3799
Post > Topic >>

Re: column default dependant on another columns value

by richard.broersma@[EMAIL PROTECTED] ("Richard Broersma") Jul 1, 2008 at 01:44 PM

On Tue, Jul 1, 2008 at 1:12 PM, Fernando Hevia <fhevia@[EMAIL PROTECTED]
>
wrote:

> Given a table with columns seconds and minutes, how can I have minutes
be
> computed automatically at the insert statement?

It is possible to do this with a trigger or a rule.  A trigger would
be more robust.

> Is this correct? Is there another (better/simpler) way to achieve this?

Well I might work, but it is a bad practice to get into since what you
are trying to do violates the rules of database normalization.

Wouldn't it be better to calculate the minutes with you query your table?

SELECT *, seconds / 60 AS minutes
  FROM yourtable;


-- 
Regards,
Richard Broersma Jr.

Visit the Los Angles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 5 Posts in Topic:
column default dependant on another columns value
fhevia@[EMAIL PROTECTED]   2008-07-01 17:12:30 
Re: column default dependant on another columns value
richard.broersma@[EMAIL P  2008-07-01 13:44:46 
Re: column default dependant on another columns value
fhevia@[EMAIL PROTECTED]   2008-07-01 18:51:27 
Re: column default dependant on another columns value
tgl@[EMAIL PROTECTED] (T  2008-07-01 18:24:24 
Re: column default dependant on another columns value
fhevia@[EMAIL PROTECTED]   2008-07-02 10:52:02 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 21:51:40 CST 2008.