write a pl/sql function if enter a value=0 then output
value=1 and vise verse with out using if and case statements.

Answer Posted / rajesh venati

Hi all this will work for that one with out using if and
case statement.

create or replace function fun(a in number) return number
is
n number;
begin
n:=mod(1,a);
return n;
end;

SQL> select fun(1) from dual;

FUN(1)
----------
0

SQL> select fun(0) from dual;

FUN(0)
----------
1

Is This Answer Correct ?    18 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I install sql?

699


Can I call a procedure inside a function?

736


What is the difference between drop and truncate commands?

703


Does a join table need a primary key?

708


What are crud methods?

732






What are the rules to be applied to nulls whilst doing comparisons?

983


How to pronounce postgresql?

761


How to return multiple rows from the stored procedure?

714


Can we use two order by clause in query?

738


Mention what are different methods to trace the pl/sql code?

746


Does sql backup shrink transaction log?

731


What is inner join in sql?

771


how many values can the set function of mysql take? : Sql dba

720


how to use like conditions? : Sql dba

782


how to escape special characters in sql statements? : Sql dba

713