Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Computed Column vs a defined column

Status
Not open for further replies.

marvin2010

Programmer
Mar 5, 2010
35
PH
Hi.

Can you please help me? I have a computed column that divides in two a certain column in a table. I then added a specific column to also do the same (w/c is divide that column the computed column is also dividing). But when I do compare the result of the two, there are discrepancies in the decimal part.

For example:

GROSS_AMT NET_AMT COMPUTED_COLUMN

15578.87 7789.44 7789.435
8699.09 4349.55 4349.545
28754.71 14377.36 14377.355

How do I balance the two (computed column and the column that holds the actual data when saved)? It is more likely that the output from the computed column will be used. In short, how do u reference a computed column?

data type of gross_amt and net amt are numeric 12, 2 (oracle 10g)

Thanks in advance.
 
To reference the value of a computed column you use the 'Getitem...' methods (string,number,etc.). You are not able to manipulate the values of a computed column via Setitem statements. You can only manipulate the computed column by modifying the expression which makes up the computed column. If you need to do this, you are better off doing the 'computing' as part of your SQL so the column is part of the result set (ie., SELECT a, b, a / b as c from TABLE WHERE ...)

Matt

"Nature forges everything on the anvil of time"
 
Oh I see...but I think what I should have said was a COMPUTED FIELD rather than a COMPUTED COLUMN...Computed field because I clicked it on a datawindow painter and not it SQL...

Also, I was trying to assign whatever value that is in the computed field (which is an amount) to a named column. It is not accurate. The computed field shows for example 14377.36 while the named filed will convert it to 14377.355
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top