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 |
Why are cursors used?
What is sap sql?
List the ways to get the count of records in a table?
How will you distinguish a global variable with a local variable in pl/sql?
how to select unique records from a table? : Sql dba
How do you optimize a stored procedure query?
what is bcp? When is it used?
Does postgresql run on the cloud?
how to include character strings in sql statements? : Sql dba
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.
what are the nonstandard string types? : Sql dba
What is the syntax and use of the coalesce function?