Home » SQL & PL/SQL » SQL & PL/SQL » Alternate to DECODE function to be used in elsif statment in PLSQL procedure
Alternate to DECODE function to be used in elsif statment in PLSQL procedure [message #667943] Thu, 25 January 2018 06:09 Go to next message
oracbeg
Messages: 16
Registered: July 2017
Junior Member
Hello Everyone,

I am trying to use a condition els if where something like decode need to be used so that the condition is true and insertion is made. I am doing this in a sql procedure and condition is like

elsif((v_DIVIDEND/Divisor)-1 < ABS(0.2)) then insert into table(Divisor,b,c) values(Dividend,y,z)......it works fine when the divisor is not zero but when divisor is zero it gives error for same. i want to rule out zero's in divisor using like another nested if condition within elsif or something like decode. i tried another if but syntax seemed to be wrong. Using Decode says it can only be used in sql statement. Any suggestions please...
Re: Alternate to DECODE function to be used in elsif statment in PLSQL procedure [message #667945 is a reply to message #667943] Thu, 25 January 2018 07:15 Go to previous messageGo to next message
Bill B
Messages: 1813
Registered: December 2004
Senior Member
elsif Divisor = 0 then
null;
elsif((v_DIVIDEND/Divisor)-1 < ABS(0.2)) then
insert into table(Divisor,b,c) values(Dividend,y,z);
end if;
Re: Alternate to DECODE function to be used in elsif statment in PLSQL procedure [message #667946 is a reply to message #667943] Thu, 25 January 2018 08:17 Go to previous message
Michel Cadot
Messages: 65946
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
Using Decode says it can only be used in sql statement.
What about CASE?

Previous Topic: how can don't use column in group by
Next Topic: load script for loading data from oracle table to excel
Goto Forum:
  


Current Time: Tue Nov 13 12:23:24 CST 2018