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

What is the difference between inner join and outer join?

0 Answers  


What type of join is sql join?

0 Answers  


what is the Default Libraries for Oracle Report 6i

0 Answers   IBM,


Why do we use procedures in pl sql?

0 Answers  


How do I add a primary key to a table?

0 Answers  






What is a record in a database?

0 Answers  


How many types of literals are available in pl sql?

0 Answers  


pl/sql testing means what ...... explain process how to find pl/sql bugs

1 Answers   Zensar,


what is a constraint? : Sql dba

0 Answers  


what is a trigger in mysql? Define different types of trigger. : Sql dba

0 Answers  


how to use myisamchk to check or repair myisam tables? : Sql dba

0 Answers  


What is a rank in sql?

0 Answers  


Categories