Home » Developer & Programmer » Reports & Discoverer » Formula Column return Null value ????
Formula Column return Null value ???? [message #181281] Sat, 08 July 2006 02:06 Go to next message
kamran.it
Messages: 265
Registered: September 2005
Location: Karachi
Senior Member
===report 6i==

there is 2 fields qty1 and qty2
qty1 has data but qty2 has not any data
but when I execute this function it return null value while qty1 has values.Why???


function CF_1Formula return Number is
temp number;
begin
temp:= :qty1+:qty2;
return(temp);
end;
icon14.gif  Re: Formula Column return Null value ???? [message #181290 is a reply to message #181281] Sat, 08 July 2006 04:49 Go to previous messageGo to next message
Rehan Mirza
Messages: 67
Registered: July 2004
Location: Pakistan
Member

use Nvl Function for yours required task
see yours correct code

function CF_1Formula return Number is
temp number;
begin
temp:= Nvl(:qty1,0)+ Nvl(:qty2,0);
return(temp);
end;


it will sole yours problem

take care
Re: Formula Column return Null value ???? [message #181299 is a reply to message #181281] Sat, 08 July 2006 05:39 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
kamran.it wrote on Sat, 08 July 2006 09:06


qty1 has data but qty2 has not any data
but when I execute this function it return null value while qty1 has values.Why???
This is expected behaviour: NULL is "the absence of a value". You could see it as "I don't know" to make it easier to understand. If you have an unknown value (NULL) and add 1 to it, how much do you get? I don't know (NULL). This approach is not perfect but it can help you understand this NULL logic.

As for the solution: Rehan Mirza has provided one.

MHE
Re: Formula Column return Null value ???? [message #181307 is a reply to message #181299] Sat, 08 July 2006 07:10 Go to previous messageGo to next message
kamran.it
Messages: 265
Registered: September 2005
Location: Karachi
Senior Member
Mr. Rehan

It is returning 0 ????

I want to do :-

temp1:= :Quantity*:price; ------ (it has values)
temp := :Pes_quantity*:Pes_price; ------(no any value)
tot := nvl(temp,0) + nvl(temp1,0);
return (tot);

result = 0


why???

[Updated on: Sat, 08 July 2006 07:15]

Report message to a moderator

Re: Formula Column return Null value ???? [message #181328 is a reply to message #181281] Sat, 08 July 2006 14:30 Go to previous messageGo to next message
dude4084
Messages: 222
Registered: March 2005
Location: Mux
Senior Member
Hi

Rule of thumb

"Null multiplied into anything will result in NULL"

So if the :Quantity or :Pes_quantity will have NULL then it will reult NULL in Temp or Temp1.

Remedy:
Use NVL function as follow:


NVL(:Quantity,0) instead of :Quantity

and

NVL(:Pes_quantity) instead of :Pes_quantity

-Dude
Re: Formula Column return Null value ???? [message #181421 is a reply to message #181328] Mon, 10 July 2006 01:06 Go to previous message
kamran.it
Messages: 265
Registered: September 2005
Location: Karachi
Senior Member
Thank You
Previous Topic: Reports: Make all columns the same height regardless of data?
Next Topic: Cont. Print in Lanscape.
Goto Forum:
  


Current Time: Fri Nov 29 22:15:49 CST 2024