← Back to team overview

dhis2-users team mailing list archive

Re: 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

Follow ups

References