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

Why self join is used in sql?

0 Answers  


What is the difference between between and in condition operators?

0 Answers  


What are the different operators available in sql?

0 Answers  


What does where 1/2 mean in sql?

0 Answers  


how to create object in plsql

2 Answers   TCS,






differentiate between float and double. : Sql dba

0 Answers  


Can a foreign key be a duplicate?

0 Answers  


I have done oracle 10g. I need a project knowledge. So if u please send a project how it should be done,Or you can send email link. I will be very grateful to u.

1 Answers  


What are the types of sql commands?

0 Answers  


what is the bond code in materialized view?

0 Answers  


I have a procedure in a procedure. The inner procedure contains out parameter. How I can call the inner procedure in the out procedure and send the inner procedure parameter value(out parameter value) into out procedure?

2 Answers  


How to return multiple records from procedure?

2 Answers  


Categories