Thanks Lars.

This is very helpful.  I have done something similar to add French translations 
for many data elements, so we should be able to figure it out with this 
guidance.

Randy

From: Lars Helge Øverland [mailto:larshe...@gmail.com]
Sent: Monday, August 26, 2013 9:42 PM
To: Morten Olav Hansen
Cc: Wilson,Randy; dhis2-users@lists.launchpad.net
Subject: Re: [Dhis2-users] Where are custom dataelement/indicator attributes 
stored

Hi Randy, its interesting to hear that you are using DHIS 2 for data dictionary 
purposes.

The tables related to data element attributes are:

attribute (you have already created those attributes so no need to insert 
anything)
attributevalue (contains reference to the attribute and holds the actual 
attribute value)
dataelementattributevalues (contains references to attributevalues and 
dataelements - links these two together)

So you must first insert the attributevalue records - should be easy to 
generate that sql from the spreadsheet:

insert into attributevalue values (nextval('hibernate_sequence'), '<Attribute 
value>', <attributeid>);

Then comes one challenge - you must know the identifier of the attributevalue 
in order to link it to the right data element:

insert into dataelementattributevalues values 
(<dataelementid>,<attributevalueid>);



Not sure how to best fix this but one way could be to create a script where you 
use the currval function and have these two sql commands alternating like this:


insert into attributevalue values (nextval('hibernate_sequence'), '<Attribute 
value>', <attributeid>);
insert into dataelementattributevalues values 
(<dataelementid>,currval('hibernate_sequence'));

insert into attributevalue values (nextval('hibernate_sequence'), '<Attribute 
value>', <attributeid>);
insert into dataelementattributevalues values 
(<dataelementid>,currval('hibernate_sequence'));


regards,

Lars




_______________________________________________
Mailing list: https://launchpad.net/~dhis2-users
Post to     : dhis2-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to