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 / 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 View All Answers
Which is faster view or stored procedure?
When can we use the where clause and the having clause?
Why self join is used in sql?
i have a column which may contain this kind of value: 123*67_80,12*8889_5,34*8_874 ,12*7_7 (can contain space before a comma, and this string length can be anything) now i want to split this value into two column like: column1: 123*67,12*8889,34*8,12*7 column2: 80,5,874,7 use function for this
What is the difference between unique and primary key constraints?
How does a covering index work?
what is the difference between delete and truncate commands? : Sql dba
Why is sql better than hql?
Which column of the user triggers data dictionary view displays the database event that will fire the trigger?
Is sqlite free?
Explain the purpose of %type and %rowtype data types with the example?
What is procedure and function in sql?
what are the differences between procedure-oriented languages and object-oriented languages? : Sql dba
What is hibernate and its relation to sql?
What is the command used to fetch the first 5 characters of a string?