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
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 |
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 |
What is the difference between inner join and outer join?
What type of join is sql join?
what is the Default Libraries for Oracle Report 6i
Why do we use procedures in pl sql?
How do I add a primary key to a table?
What is a record in a database?
How many types of literals are available in pl sql?
pl/sql testing means what ...... explain process how to find pl/sql bugs
what is a constraint? : Sql dba
what is a trigger in mysql? Define different types of trigger. : Sql dba
how to use myisamchk to check or repair myisam tables? : Sql dba
What is a rank in sql?