function CF_TOTAL_PARESFormula return Number is
vtotal_pares number(8);
begin
if :pares_linha > 0 then
vtotal_pares := :pares_linha;
else
vtotal_pares := 0;
end if;
if vtotal_pares = 0 then
return(0);
else
return(vtotal_pares);
end if;
end;
Extremely doubtful IF
-
- Rank: DBA Júnior
- Posts: 229
- Joined: Fri, 05 Sep 2008 2:59 pm
- Location: Igrejinha - RS
I found this this morning ...
-
- Moderador
- Posts: 641
- Joined: Mon, 03 Sep 2007 3:26 pm
- Location: Fortaleza - CE
att,
Daniel N.N.
Daniel N.N.
Apparently, the person who was testing wanted it to be assigned the value 0.
What is cooler is not having another if but the other is completely dispensable.
to make a simple return (v_total_par).
If you can see if it is 0 variable, return 0:
What is cooler is not having another if but the other is completely dispensable.
to make a simple return (v_total_par).
If you can see if it is 0 variable, return 0:
if vtotal_pares = 0 then
return(0);
else
return(vtotal_pares);
end if;
-
- Rank: DBA Júnior
- Posts: 229
- Joined: Fri, 05 Sep 2008 2:59 pm
- Location: Igrejinha - RS
It is neither the question of avoiding negative pairs.
Thinking a little more on business rule, it is impossible to have negative pairs.
Soon, the solution would be very, but much simpler.
and if you want to simplify even more, simply put the NVL straight into Query: P
Thinking a little more on business rule, it is impossible to have negative pairs.
Soon, the solution would be very, but much simpler.
RETURN NVL(:pares_linha, 0);
- dr_gori
- Moderador
- Posts: 5024
- Joined: Mon, 03 May 2004 3:08 pm
- Location: Portland, OR USA
- Contact:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
From what I understood, if the number is negative, you have to go to zero.
Then something like this:
or, can do in a line only:
Then something like this:
IF :pares_linha <= 0 --Se for menor que zero, retorna zero.
THEN return 0;
ELSE return :pares_linha; --Senão, retorna o próprio numero.
END IF;
RETURN DECODE ( SIGN(:pares_linha), -1, 0, :pares_linha)
-
- Rank: DBA Júnior
- Posts: 229
- Joined: Fri, 05 Sep 2008 2:59 pm
- Location: Igrejinha - RS
Auheuaheuahe: P
- dr_gori
- Moderador
- Posts: 5024
- Joined: Mon, 03 May 2004 3:08 pm
- Location: Portland, OR USA
- Contact:
Thomas F. G
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered
Interesting how much interpretation can generate a doubtful code without comments ... That's where we waste time, trying to guess what's on the head of the guy who did ..: roll:
-
- Information
-
Who is online
Users browsing this forum: No registered users and 1 guest