I have created a package with the search_order function that receives F_Order as a parameter
create or replace PACKAGE BUSCAR_ORDER_PKG IS
FUNCTION buscar_order (F_Order VARCHAR2)
RETURN VARCHAR2;
END BUSCAR_ORDER_PKG;
The function is executed as such but when the parameter is empty it returns the error ORA-06503: PL/SQL: Function returned without value and from there it does not happen even when it has an exception.
create or replace PACKAGE BODY BUSCAR_ORDER_PKG IS
FUNCTION buscar_order(F_Order VARCHAR2)
RETURN VARCHAR2 IS
l_order varchar2(150);
Begin
Select Flex_Value
Into l_Order
From Flex_Values
Where Flex_Value_Id = (Select Flex_Value_Id
From Flex_Values
Where Flex_Value_Name = 'PROJECT')
And Flex_Value = NVL(F_Order,'X')
And Enabled_Flag = 'Y'
And Trunc(Nvl(End_Date_Active,Sysdate)) >= Trunc(Sysdate);
Exception
WHEN OTHERS THEN
l_Order := null;
end buscar_order;
END BUSCAR_ORDER_PKG;