Reputation: 21
I was using AnyChart for all my chart in Apex 5. Now that I upgraded to 18.2, AnyChart is now "legacy". So, I wanted to update my chart to use JET Chart.
My chart used "PL/SQL Function Body returning SQL Query". My PL/SQL Function body build my query dynamicaly and my number of series displayed may varied. As I don't know how many series I will have, I'm not able to set my series in my chart.
Here's my PL/SQL Function Body:
DECLARE
l_selected APEX_APPLICATION_GLOBAL.VC_ARR2;
l_sql VARCHAR2(4000) := '';
BEGIN
--
-- Convert the colon separated string of values into a PL/SQL array
l_sql := l_sql || 'SELECT NULL link ';
l_sql := l_sql || ' ,year_month label ';
l_selected := APEX_UTIL.STRING_TO_TABLE(:P16_SELECT_LIST);
--
-- Loop over array to insert department numbers and sysdate
IF l_selected.count = 0 THEN
l_sql := l_sql || ' ,NULL "no data" ';
ELSE
FOR i IN 1..l_selected.count LOOP
l_sql := l_sql || ',MIN(DECODE(sqn, '''||l_selected(i)||''', srt_cnt, NULL)) "'||l_selected(i)|| CASE WHEN REGEXP_LIKE(TRIM(l_selected(i)), '^[[:digit:]]') THEN ' Sqn' ELSE NULL END||'"';
END LOOP;
END IF;
l_sql := l_sql || ' FROM flight_and_mmh t ';
l_sql := l_sql || ' WHERE snapshot_fk = :P27_SNAPSHOT_LIST ';
l_sql := l_sql || ' AND INSTR('':'' || :P16_SELECT_LIST || '':'' , '':'' || sqn || '':'') > 0 ';
l_sql := l_sql || ' GROUP BY t.year_month ';
l_sql := l_sql || ' ORDER BY t.year_month ';
RETURN l_sql;
END;
Upvotes: 2
Views: 2324
Reputation: 435
Theres no need to use dynamic sql for multiple series in apex nowadays.
In the series region select: series => Source => Region Source
Then put your sql query in the main region source code.
Back in the series => Column Maping, u need to choose the VALUE, the LABEL and the SERIES NAME with the respective columns of your query.
Upvotes: 1