sql - Description of the following code? -
i have situation programmer has developed stored procedure absent , doesn't work anymore, have make little bit of update code. should add 2 more variables in code , know place, don't know how put it.. please describe following code, in terms of sql? cause know code stand inside programm..
raise notice 'stat card: formid=%',formid; drop table if exists tbl_aggregation; -- execute sql_ := 'create temporary table tbl_aggregation ' --select programstageinstanceid,'|| dynamic_columns ||' patientdatavalue' ||' select orgunitid , max(dateperiod) dateperiod , programstageinstanceid , max("[de:202062.202063.575]"::integer) "[de:202062.202063.575]" , max( (case when position(''-'' in "[de:202062.202063.202095]")>0 substring("[de:202062.202063.202095]" 0 position(''-'' in "[de:202062.202063.202095]")) else "[de:202062.202063.202095]" end) ) "[de:202062.202063.202095]" , sum("[de:202062.202063.202078]"::integer) "[de:202062.202063.202078]" , max("[de:202062.202063.202076]") "[de:202062.202063.202076]" ( select psi.organisationunitid orgunitid , ou.name orgname, pdv.timestamp dateperiod , pdv.programstageinstanceid , pdv.dataelementid , pdv.value,' || dynamic_columns ||' patientdatavalue pdv inner join programstageinstance psi on pdv.programstageinstanceid = psi.programstageinstanceid -- left join organisationunit ou inner join tbl_org_list ou on psi.organisationunitid = ou.organisationunitid psi.completed=''t'' , psi.duedate >= '''||period_from ||''' , psi.duedate <= '''||period_to ||''' )as aggregation_ '||ccondition||' group programstageinstanceid, orgunitid ';
in code there hard-coded "variables" [de:202062.202063.575]
, , [de:202062.202063.202078]
, etc.. have 2 more different [de:xxx,xxx,xx]
should add here.
because whenever run storing procedure doesn't work , gives error new [de:xxx,xxx,xx]
doesn't exist.. should make them exist in code, put them? have understand sql syntax , does, , unfortunately i'm noob in sql.
Comments
Post a Comment