Reputation: 61
now I have almost finished my PL / SQL code in APEX. I have been stuck with a mistake since yesterday.
While X < l_date_diff+1 Loop
l_date_string := l_date_string ||''','''||to_char(TO_DATE(:P2066_DATE_FROM, 'dd.mm.yyyy')+X,'dd.mm.yyyy') ;
X := X + 1;
End Loop;
l_date_string := substr(l_date_string,3)|| chr(39);
l_script := 'Select * from
(Select
pkey,
to_char(createdformat,''dd.mm.yyyy'') business_date,
regexp_substr(statistics, ''business_\w*'') business_statistics
from
gss.business_data
where
statistics like ''%business_%''
and createdformat between :P2066_DATE_FROM and :P2066_DATE_UNTIL
) ';
l_script_pivot := l_script || ' pivot(
count(pkey)
for business_date
in ('||l_date_string||')
)';
I built the code step by step and so I could define exactly where the error occurs.
When returning "Return" I now get the error: ORA-20999: Parsing returned query results in "ORA-20999: SQL query could not be parsed.
ORA-06550: row 18, column 6: ORA-01756: quote missing from string
".If I just return the first part instead of l_script_pivot, i.e. l_script and look at the value of l_script_pivot, the code looks correct. I could even enter it in SQL and get a result. Somewhere I am missing an apostrophe in the compound string l_script_pivot
Upvotes: 0
Views: 125
Reputation: 169
while X < l_date_diff+1
Loop
l_date_string := l_date_string||','||to_char(TO_DATE(:P2066_DATE_FROM,'dd.mm.yyyy')+X,'dd.mm.yyyy') ;
X := X + 1;
End Loop;
l_script := 'Select * from
(Select
pkey,
to_char(createdformat,"dd.mm.yyyy") business_date,
regexp_substr(statistics, "business_\w*") business_statistics
from
gss.business_data
where
statistics like "%business_%"
and createdformat between :P2066_DATE_FROM and :P2066_DATE_UNTIL
) ';
l_script_pivot := l_script || ' pivot(
count(pkey) for business_date in (l_date_string)
)';
Upvotes: 0