I have below code in the function. As long as I don't use any variable which is a date, it works. The moment I add date variable, it fails and application results in the interactive report show .ORA-00904: "D"."W6": invalid identifier
The code validation works though and it gets saved without any errors.
Sample code that is similar to my code:
DECLARE
VAR1 VARCHAR2(2000) := NULL;
VAR2 VARCHAR2(2000) := NULL;
VAR3 VARCHAR2(2000) := NULL;
VAR99 :=NULL;
I NUMBER := 0;
PREV_SUN DATE := NULL;
NEXT_SUN NUMBER := NULL;
diff number :=null;
BEGIN
PREV_SUN := TO_DATE(NEXT_DAY(
:P81_END_DT,
'SUN'
) - 7,'DD-MON-YY');
NEXT_SUN := to_number(TO_CHAR(TO_DATE(NEXT_DAY(:P81_END_DT,'SUN'),'DD-MON-YY'),'IW'));
diff:=next_sun-0;
VAR1:= 'select ';
VAR2:= to_number(diff) || ( 2 + ( I - 1 ) );
VAR3:=' from dual';
VAR99:=VAR1||VAR2||VAR3;
RETURN VAR99;
END;
If VAR2:=( 2 + ( I - 1 ) ); is used, it works because 'diff' is not used. I tried using the variable in many ways, but no luck yet.
Aren't date functions supported?