Can we do the conditional declarations of variables in pl/sql functions or procedures? For example can we do something like below:
CREATE OR REPLACE FUNCTION get_total_sales(
in_year PLS_INTEGER
)
RETURN NUMBER
IS
IF condtion THEN
variable_name_1 BINARY_FLOAT;
ELSE
variable_name_2 NUMBER;
END;
BEGIN
--- Function Logic
END;
If the condition is met, I need to declare a variable called variable_name_1 and if not I don't want to declare it and instead need to declare a variable called variable_name_2.
conditionevaluated - at compile time, based on environment (e.g. dev/prod, customer licence) or are you trying to change this at run time for each call?