Function in Oracle Sql

Asked

Viewed 39 times

0

How do I perform these if Else in SQL

create or replace function inss(x real)
return number is
begin 
    if x <= 840.55 then 
        return ((7.65/100) * x);
    else if (x >= 840.56) and (x <= 1050.00) then 
        return ((8.65/100) * x);
    else if (x >= 1050.01) and (x <= 1400.91) then 
        return ((9/100) * x);
    else if (x >= 1400.92) and (x <= 2801.82) then 
        return ((11/100) * x);
    else 
        return 308.20;
    end if;
end;

You’re making that mistake

Errors: FUNCTION INSS Line/Col: 15/4 PLS-00103: Encountered the Symbol ";" when expecting one of the following:

if

  • Place elsif in place of else if

  • It worked, but could you teach me why if it doesn’t work? I use 10g in college and the teacher didn’t teach this way, it would be on account of upgrades?

  • In the construction you used you will need a end if; for each if, what is not necessary in construction elseif.

  • Now I understand, thank you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.