sql - How optimized deprecated left outer join query on multiple column of more than two similar tables in postgres -
i have below query in oracle , need convert postgres . have created function table dynamicaly risk1,risk2, risk 3 subquery because have same contents except parameter . how can minimize code left outer join. because after creating function postgres gives error below error:-
error: not write tuplestore temporary file: no space left on device
oracle code :-
select (select perimeter.description t_perimeter_nrvl perimeter perimeter.level_no $p{levelno} , perimeter.perimeter_id =risk1.perimeter_id) per_name, risk1.control_id, risk1.name, risk1.control_instr, nvl(to_char(risk1.declaration_date,'dd/mm/yy'),' ')declaration_date, risk1.risk_indicator indicator1, risk2.risk_indicator indicator2, risk3.risk_indicator indicator3, risk4.risk_indicator indicator4, risk5.risk_indicator indicator5 (select ctrl.control_id,ctrlml.name,ctrlml.control_instr t_control_nrvl ctrl,t_riskindicator_nrvl risk, t_control_ml_nrvl ctrlml , ctrlml.riskid =risk.riskid , ctrl.control_id=ctrlml.control_id , ctrlml.language_id=$p{languageid} , ctrl.control_type='ms' , decl.deadline >= $p{startdate} , decl.deadline <= $p{enddate} , risk.indicator_id = 'r1') risk1, (select ctrl.control_id,ctrlml.name,ctrlml.control_instr t_control_nrvl ctrl,t_riskindicator_nrvl risk, t_control_ml_nrvl ctrlml , ctrlml.riskid =risk.riskid , ctrl.control_id=ctrlml.control_id , ctrlml.language_id=$p{languageid} , ctrl.control_type='ms' , decl.deadline >= $p{startdate} , decl.deadline <= $p{enddate} , risk.indicator_id = 'r2') risk2, (select ctrl.control_id,ctrlml.name,ctrlml.control_instr t_control_nrvl ctrl,t_riskindicator_nrvl risk, t_control_ml_nrvl ctrlml , ctrlml.riskid =risk.riskid , ctrl.control_id=ctrlml.control_id , ctrlml.language_id=$p{languageid} , ctrl.control_type='ms' , decl.deadline >= $p{startdate} , decl.deadline <= $p{enddate} , risk.indicator_id = 'r3') risk3 risk1.control_id = risk2.control_id(+) , risk1.control_id =risk3.control_id(+) , risk1.declaration_id = risk2.declaration_id(+) , risk1.declaration_id =risk3.declaration_id(+) , risk1.perimeter_id = risk2.perimeter_id(+) , risk1.perimeter_id =risk3.perimeter_id(+) order risk1.control_id
i have written query in postgres runs gives error:-
select (select perimeter.description t_perimeter_nrvl perimeter perimeter.level_no '001004002011' , perimeter.perimeter_id =risk1.perimeter_id) per_name, risk1.control_id, risk1.ctrlmlname, risk1.control_instr, coalesce(to_char(risk1.declaration_date,'dd/mm/yy'),' ')declaration_date, risk1.risk_indicator indicator1, risk2.risk_indicator indicator2, risk3.risk_indicator indicator3, risk4.risk_indicator indicator4, risk5.risk_indicator indicator5 (select * fn_getriskindicater('r1','001004002011','en','30-03-2015','30-06-2016')) risk1 left join (select * fn_getriskindicater('r2','001004002011','en','30-03-2015','30-06-2016')) risk2 on risk1.control_id = risk2.control_id left join (select * fn_getriskindicater('r3','001004002011','en','30-03-2015','30-06-2016')) risk3 on risk1.control_id =risk3.control_id left join (select * fn_getriskindicater('r2','001004002011','en','30-03-2015','30-06-2016')) risk6 on risk1.declaration_id = risk6.declaration_id left join (select * fn_getriskindicater('r3','001004002011','en','30-03-2015','30-06-2016')) risk8 on risk1.declaration_id = risk8.declaration_id left join (select * fn_getriskindicater('r2','001004002011','en','30-03-2015','30-06-2016')) risk11 on risk1.perimeter_id = risk11.perimeter_id left join (select * fn_getriskindicater('r3','001004002011','en','30-03-2015','30-06-2016')) risk12 on risk1.perimeter_id = risk12.perimeter_id order risk1.control_id
Comments
Post a Comment