Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-29 Thread moses mwale
Alright thanks Jason on it. On Mon, Jan 29, 2018 at 1:10 PM, Jason Pickering < jason.p.picker...@gmail.com> wrote: > Hi Moses, > > The version of the function looks to be a bit outdated. I just updated it > again in this commit >

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-29 Thread moses mwale
Thanks very much it has worked just analyzing the data now. You a savior. On Mon, Jan 29, 2018 at 1:20 PM, moses mwale wrote: > Alright thanks Jason on it. > > On Mon, Jan 29, 2018 at 1:10 PM, Jason Pickering < > jason.p.picker...@gmail.com> wrote: > >> Hi Moses, >> >>

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-29 Thread Jason Pickering
Hi Moses, The version of the function looks to be a bit outdated. I just updated it again in this commit . Maybe you can try again with this new version and see if it works? Regards, Jason On Mon, Jan 29,

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-29 Thread moses mwale
wow some major progress i thought it was special sql. I now know its normal sql. dhis2_test=> SELECT merge_organisationunits('FfX6DGeVsJd', 'qqkYhasbAcf' ,'SUM'); ERROR: column "attributeoptioncomboid" is of type integer but expression is of type character varying LINE 6: value, ^ HINT:

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-29 Thread Jason Pickering
Hi Moses, You need to use the UID of the organisation unit not their integer ID. You need to place string literals in single quotes. So, it should be something like SELECT merge_organisationunits('foo', 'bar' ,'SUM'); Regards, Jason On Sun, Jan 28, 2018 at 5:28 PM, moses mwale

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-28 Thread moses mwale
Hello Jason, Knut and Bob I did according to your per instruction, i had a dump or copy of the db, i created a test db with it and loaded the functions then called using the shared query dhis2_test=> SELECT merge_organisationunits(37442, 24872 ,SUM); ERROR: column "sum" does not exist LINE 1:

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-25 Thread moses mwale
Thanks all you are really help i appreciate so much. let me do test first on the backed up db if satisfied will run the merge on the Prod. Thanks. On Fri, Jan 26, 2018 at 3:24 AM, Bob Jolliffe wrote: > If you really must work on your production database directly then at >

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-25 Thread Bob Jolliffe
If you really must work on your production database directly then at the very least you should shutdown the dhis2 instance while you make changes. Naturally you want to keep that down time to a minimum. So I would suggest a sequence of: (i) make a copy of the database to test these procedures

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-25 Thread Jason Pickering
Hi again Moses, The function itself should not affect anything, but its never a good idea to do these things directly on a production database without extensive testing. Note that this function WILL remove data depending on whether its overlapping. So, if you have two data values for the same

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-25 Thread moses mwale
This is live (Production) db created a backup. if something goes wrong will revert. But the function itself doesnt affect anything right? what am going to write now will i guess by merging duplicate orgs right? On Fri, Jan 26, 2018 at 2:59 AM, Jason Pickering < jason.p.picker...@gmail.com> wrote:

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-25 Thread Jason Pickering
That looks correct. It is of course worth saying, that you should not attempt to perform this procedure on your production system, unless you have thoroughly tested it in a development environment! Regards, Jason On Thu, Jan 25, 2018 at 1:55 PM, moses mwale wrote: >

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-25 Thread moses mwale
Am using psql. see attached if its correct loading procedure. On Fri, Jan 26, 2018 at 2:42 AM, Knut Staring wrote: > Just run everything in your PgAdmin SQL interface. > > On Thu, Jan 25, 2018 at 1:22 PM, moses mwale > wrote: > >> okay nice thanks, is

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-25 Thread Knut Staring
Just run everything in your PgAdmin SQL interface. On Thu, Jan 25, 2018 at 1:22 PM, moses mwale wrote: > okay nice thanks, is it to load user-defined functions the same way you > load stored procedures, by packaging the Java class or classes into a JAR > file and then

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-25 Thread Jason Pickering
Hi Moses These are simply Postgresql functions, which you load and execute directly in the database. These are completely external of DHIS2, so you will need to do this operation directly in the database environment. Regards Jason On Thu, Jan 25, 2018 at 1:22 PM, moses mwale

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-25 Thread moses mwale
okay nice thanks, is it to load user-defined functions the same way you load stored procedures, by packaging the Java class or classes into a JAR file and then loading the JAR file using the LOAD CLASSES statement? On Thu, Jan 25, 2018 at 11:38 PM, Jason Pickering < jason.p.picker...@gmail.com>

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-25 Thread Jason Pickering
Hi Moses, You need to load both of those functions into your database. 1) Script to delete an orgunit is here 2) Script to merge two orgunits is here

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-24 Thread moses mwale
Hey Jason And Knut, thanks for the information, i have been trying to understand the sql script shared and tried to execute but to no effect, please can you help me understand where to place the source id and orgunit ids in the script after several attempts of try its has became more complex. I

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-07 Thread moses mwale
Thanks very much, allow me to go through and implement the given knowledge On Sun, Jan 7, 2018 at 11:29 PM, Jason Pickering < jason.p.picker...@gmail.com> wrote: > Hi Moses > We have some SQL scripts for this here. > > https://github.com/dhis2/dhis2-utils/blob/master/ >

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-07 Thread Jason Pickering
Hi Moses We have some SQL scripts for this here. https://github.com/dhis2/dhis2-utils/blob/master/resources/sql/merge_orgunits.sql This script will not handle tracker data but could probably be adapted fairly easily to do so. Regards, Jason On Jan 7, 2018 7:28 AM, "Knut Staring"

Re: [Dhis2-devs] merging facilities (org-units) without losing data

2018-01-06 Thread Knut Staring
Hi Moses, I would take a backup of the database and then do this with an sql script, just changing the sourceid (the database internal referent to the organisationunitid) in the datavalues table. But you may get blocked if the same period has been filled for both, in which case you may want to do