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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / ajitnayak

create or replace function vice_versa2 (inp_no number) return number
is
a number := 0;
begin

select decode(inp_no, 1, 0,1) into a from dual;

return a;

end;

Is This Answer Correct ?    1 Yes 0 No

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

Answer / sachin sapkal

create or replace function myfun(a in number) return number
is
n number;
begin
if (n = 1)
return 0;
else if(n = 0)
return 1;
else
dbms_output.put_line('enter 0 or 1 only...');
end if;
end;

SQL> select myfun(1) from dual;

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More SQL PLSQL Interview Questions

Like shown below i have 3 columns(Name,No,Address). The values in name column i want to modity. Requirement : Keep only once space between two words (Fname,Lname) in the Name column. For this what is the query? Please answer me. Advance Thanks. Name No Address Reference manoj kumar kumar raja vinzay kumar rajendra prasad gowri nath -- -- --

5 Answers  


How can i insert data inro a table with 3 columns using FORALL?

2 Answers   Oracle,


Does oracle roll back the transaction on an error?

0 Answers  


What is the difference between instead of trigger and after trigger?

0 Answers  


How do I create an index in word?

0 Answers  






What is Referential Integrity?

3 Answers  


What are tables and fields in the database?

0 Answers  


What is the difference between union and union all command?

0 Answers  


what is a table in a database ? : Sql dba

0 Answers  


What is crud sql?

0 Answers  


Can 2 queries be executed simultaneously in a distributed database system?

0 Answers  


What is the difference between an inner join and an outer join?

0 Answers  


Categories