Oracle PL/SQL function that takes a string as a parameter.
What is the correct syntax for including this parameter in the Select portion of a statement.
The function is :
create or replace function GetHorizonTime(HorizonWindowMinutes IN VARCHAR2)
return timestamp
IS
RETVALUE TIMESTAMP;
BEGIN
SELECT SYSDATE + Interval '''||HorizonWindowMinutes||''' MINUTE INTO RETVALUE
FROM DUAL;
RETURN RETVALUE;
END;
/
SELECT GetHorizonTime('720') FROM DUAL;
The select statement should translate to:
SELECT SYSDATE + Interval '720' MINUTE INTO RETVALUE
FROM DUAL;
HorizonWindowMinutesshould be a number. Then you'd pass that number to thenumtodsintervalfunction rather than constructing an interval literal. You could still do that ifHorizonWindowMinutesis a string that only has numeric data using implicit conversion but that wouldn't generally make sense.