Are you sure your v_totao_no_system is not 0?
It is.
See if that's what you meant
UPDATE answer SET
value = (select (number_system/v_total_no_system) * 100 from
answer
where question_id = 50)
where question_id = 50;
Littlefoot
05-06-04, 02:46
When dividing two numbers, one should know their names. They are not just number1 and number2 or something like that, but dividendand divisor. Number you get as a result is called a quotient.
dividend
--------- = quotient
divisor
As you probably know (and, if not, use a calculator), when a divisor equals zero (0), the result (quotient) is indefinite.
You can do something about it, however, using the decode function:
UPDATE answer SET
value =
(SELECT (number_system /
DECODE(v_total_no_system, 0, 1e-99,
v_total_no_system
)
) * 100
FROM answer
)
WHERE question_id = 50;
Doing so, 1E-99 (which stands for 0.00...001 - a decimal number which has 1 on 99th place behind a decimal sign) is something like 0 and the quotient will be VERY large number (unless dividend is, of course, similar to divisor), but it will not lead you to ORA-01476 error.
I guess answer.value is a NUMBER and will not be able to hold such a huge value. Therefore, substitute 1E-99 with 1E99 and the result will then be not something_large, but 0.
Or, ensure that data used as divisors are not equal to 0 (check constraint or something like that).
Phew!
Thanks for the suggestions!
vBulletin v3.5.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.