sql - Formula / Calculation columns in a database table -


i dno't think possible or makes sense, people here smarter me , never hurts ask. possible create table in database formula. don't mean query. mean let's have table , 1 of columns "price" 1 "quantity" , column "cost" calculate (price * quantity) .... data gets imported. later can just:

select * table;

if tell me stupid question i'll understand got internal client , need investigate it. db running db2 on bluemix.

you can set default value cost column as

alter table table-name alter column cost set cost=price*quantity; 

or can create trigger follows,

db2 create trigger trigger_name after insert on table_name  each row mode db2sql begin atomic update tablle_name  set cost=qty*price; end   

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -