sql - My query isn't populating data in Apex Charts but it works in Toad -
select null link, a.time_frame "start_date", (a.row_number*(regr_slope(a.failures, a.row_number) on (partition a.state)) + (regr_intercept(a.failures, a.row_number) on (partition a.state))) trendline ( select row_number() on (order (case :p1_date_chooser when 'daily' trunc(start_time) when 'weekly' trunc(start_time, 'ww') when 'monthly' trunc(start_time, 'mm') end)) row_number, (case :p1_date_chooser when 'daily' trunc(start_time) when 'weekly' trunc(start_time, 'ww') when 'monthly' trunc(start_time, 'mm') end) time_frame, count(job_id) failures, state --from apps.ni_infa_activity_log_v@util.world ni_infa_activity_log_v state = 1 , ( :p1_job_type_chooser = 'workflow' , infa_type_code = 'workflow' or :p1_job_type_chooser = 'dss' , infa_type_code = 'dss' or :p1_job_type_chooser = 'mtt' , infa_type_code = 'mtt' or :p1_job_type_chooser not in ('workflow','dss','mtt') ) group (case :p1_date_chooser when 'daily' trunc(start_time) when 'weekly' trunc(start_time, 'ww') when 'monthly' trunc(start_time, 'mm') end), state order state,(case :p1_date_chooser when 'daily' trunc(start_time) when 'weekly' trunc(start_time, 'ww') when 'monthly' trunc(start_time, 'mm') end) ) group a.row_number, a.time_frame,a.failures, a.state order a.state,a.row_number;
in middle source. query works in toad when move oracle apex app developer chart won't populate data. change made switch clauses around in middle. know "apps.ni_infa_activity_log_v@util.world" works source because i'm using inside other queries in app. if rid of case/whens , switch them single line trunc(start_time) itself, data populates. appreciated.
table , sample data:
create table ni_infa_activity_log ( task_id varchar2(30 byte) , object_name varchar2(1000 byte) , job_id varchar2(30 byte) not null , infa_type_code varchar2(10 byte) , run_id number(10) , start_time date , end_time date , state number(1) ); insert ni_infa_activity_log (task_id, object_name, job_id, infa_type_code, run_id, start_time, end_time, state) values ( '000t0w0n0000000000000u' , 'campsync_erp_sfdc_v1.2' , '000t0wc1000000001i6w' , 'workflow' , null , to_date('5/22/2015 11:20:10','mm/dd/yyyy hh24:mi:ss') , to_date('5/22/2015 11:21:02','mm/dd/yyyy hh24:mi:ss') , 1 ); insert ni_infa_activity_log (task_id, object_name, job_id, infa_type_code, run_id, start_time, end_time, state) values ( '000t0w0n00000000000h' , 'pmdm_ora_ora_clnload_v1.0' , '000t0wc1000000001j5x' , 'workflow' , null , to_date('5/24/2015 10:30:11','mm/dd/yyyy hh24:mi:ss') , to_date('5/24/2015 10:32:34','mm/dd/yyyy hh24:mi:ss') , 1 ); commit;
i found solution. i'm not entirely why made work in apex though:
select null link, tf.time_frame label, (tf.row_number*(regr_slope(count(data.job_id), tf.row_number) on (partition data.state)) + (regr_intercept(count(data.job_id), tf.row_number) on (partition data.state))) trendline apps.ni_infa_activity_log_v@util.world data , ( select rownum row_number, time_frame ( select case :p1_date_chooser when 'daily' trunc(start_time) when 'weekly' trunc(start_time, 'ww') when 'monthly' trunc(start_time, 'mm') end time_frame apps.ni_infa_activity_log_v@util.world group case :p1_date_chooser when 'daily' trunc(start_time) when 'weekly' trunc(start_time, 'ww') when 'monthly' trunc(start_time, 'mm') end order 1 ) ) tf tf.time_frame = (case :p1_date_chooser when 'daily' trunc(data.start_time) when 'weekly' trunc(data.start_time, 'ww') when 'monthly' trunc(data.start_time, 'mm') end) , state = 1 , ( :p1_job_type_chooser = 'workflow' , data.infa_type_code = 'workflow' or :p1_job_type_chooser = 'dss' , data.infa_type_code = 'dss' or :p1_job_type_chooser = 'mtt' , data.infa_type_code = 'mtt' or :p1_job_type_chooser not in ('workflow','dss','mtt') ) group tf.time_frame, tf.row_number, data.state
Comments
Post a Comment