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

Explain normalization and what are the advantages of it?

517


what is the difference between primary key and unique key? : Sql dba

528


Can we call dml statement in function?

541


What are the disadvantages of file system?

617


Enlist some predefined exceptions?

581






What is coalesce in sql?

560


Explain ddl statements in pl/sql?

578


What are different clauses used in sql?

587


Can we perform dml on view?

555


What is cursor in pl sql with examples?

481


How many sql databases can you have on one server?

594


what is bcp? When does it used? : Sql dba

522


How do I write a cron which will run a sql query and mail the results to agroup?

525


Which table is left in join?

516


Explain the the delete statements in sql?

579