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 are cursors used?

0 Answers  


What is sap sql?

0 Answers  


List the ways to get the count of records in a table?

0 Answers  


How will you distinguish a global variable with a local variable in pl/sql?

0 Answers  


how to select unique records from a table? : Sql dba

0 Answers  






How do you optimize a stored procedure query?

0 Answers  


what is bcp? When is it used?

0 Answers  


Does postgresql run on the cloud?

0 Answers  


how to include character strings in sql statements? : Sql dba

0 Answers  


i have a customer table. trans_id trans_date trans_amt debit_credit_indicator 001 01-JAN-13 1099 cr 001 12-JAN-13 500 db 002 24-FEB-13 400 db 002 23-MAR-13 345 cr 001 18-APR-13 800 cr 002 15-MAR-13 600 db 001 12-FEB-13 200 cr i want like this output. trans_id trans_amt debit_credit_indicator i want get highest credit amount and lowest credit amount and highest debit amount and lowest debit amount for each trans_id.

2 Answers   Oracle,


what are the nonstandard string types? : Sql dba

0 Answers  


What is the syntax and use of the coalesce function?

0 Answers  


Categories