Swadhin Ray
asked on
Function to return yes or no
Hello Experts,
I want to create a function which will return me "YES" or "NO"
The input to the function can be varchar2 ...
So if the input values if not null then return "YES"
else if the input is null then return "NO';
I want to create a function which will return me "YES" or "NO"
The input to the function can be varchar2 ...
So if the input values if not null then return "YES"
else if the input is null then return "NO';
ASKER
What are the other ways we can do it ?
ASKER
the one you gave I have already done it but still want to know any other method ..
typo in my previous post. use this. this works for me.
create or replace function f1 ( input varchar2) return varchar2 is
begin
if ( input is not null )
then
return 'YES';
else return 'NO';
end if;
end;
/
to test it :
select f1('testing') results from dual; -- returns YES
select f1('') results from dual; -- returns NO
create or replace function f1 ( input varchar2) return varchar2 is
begin
if ( input is not null )
then
return 'YES';
else return 'NO';
end if;
end;
/
to test it :
select f1('testing') results from dual; -- returns YES
select f1('') results from dual; -- returns NO
what i meant was we can use CASE or DECODE or NVL etc instead of IF clause in the function code. It does not really matter much to mention but yes we can use any of the above functions/constructs to get this function done.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
create function f1 ( input varchar2) return varchar2 is
begin
if input is not null then
return 'YES';
else return 'NO'
end if;
end;
/