Using conditinal operator in Formula column [message #381680] |
Mon, 19 January 2009 03:51 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
mahantesh
Messages: 28 Registered: March 2008 Location: Mumbai ,India
|
Junior Member |
|
|
Hi,
I want ask that can we use conditional operator in the PL/SQL formula section of formula column, If not then how can we use conditional operators on formula column.
I want to compare whether :CP_rev is less than zero or not for this i had written PL/SQL code on formula column function as
function CF_GOPFormula return Number is
begin
IF :CP_REV <=0 THEN
srw.message(10,'Revenue is null');
srw.message(10,'Revenue is null');
return 0;
ELSE
return :CP_Rev-:CP_Cost;
END IF;
end;
but i am not getting required effect, can anybody give me hint
|
|
|
Re: Using conditinal operator in Formula column [message #381776 is a reply to message #381680] |
Mon, 19 January 2009 14:57 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](http://www.orafaq.com/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21818 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
I don't have Reports 6i, but such a code works perfectly OK on 10g. By the way, what doesQuote: | i am not getting required effect
| exactly mean?
My sample query was simple:select -10 cp_rev, 5 cp_cost
from dual
Formula column was taken from your example:function CF_1Formula return Number is
begin
if :cp_rev <= 0 then
return 0;
else
return :cp_rev - :cp_cost;
end if;
end;
I have modified the CP_REV value to a positive value, and formula column's value was displayed properly.
|
|
|