Hi,
I know that we can have User Defined Functions (UDFs) for columns but is it possible to have UDFs for each cell (like we can define functions for each cell in excel). Heres the situation:
I have a database table that will have multiple fields. Some of the columns will be functions of other columns. One of the columns has variable functions.
Heres an example:
TABLE(A, B, C, D)
Total Records = 9;
A
If you notice, for Column D, some of the cells have a different formula than others. Is this doable?
Thanks...
One possible way would be there was an Id column with value 1-9, once the table was populated to make an update stored procedure calculate column unconditionally and column D according to a formula.
|||Please let me know if I am going off-track here but this is what I understood from what you wrote.
Have an ID column (say autoincrement integers), then when all the values are being populated, I run an UPDATE stored procedure which whould check if ID is from 1-4, then assign the same value otherwise if ID = 5 to 9, perform calculation.
|||
Instead of an Identity column you could just populate it manually.
Incidentally as an alternative you could drop columns C and D from the table, sum A + B to get column C and use a function reading Id, A, B to get column D in the select.
|||TATWORTH:
drop columns C and D from the table, sum A + B to get column C and use a function reading Id, A, B to get column D in the select
Does that mean I won't have columns C and D in the schema but will be generated dynamically when SELECTed (they won't ever be in the schema).
|||>Does that mean I won't have columns C and D in the schema but will begenerated dynamically when SELECTed (they won't ever be in the schema).
Yes!
No comments:
Post a Comment