cancel
Showing results for 
Search instead for 
Did you mean: 

Changing FK specification i.e. changing data type of foreign key in LDM

Former Member
0 Kudos

Hi,

I'm trying to change data type of a foreign key if it's parent attribute is defined with serial data type in LDM.

I have created an extension , added a metaclass - 'Relationship' to it and then, added an event handler - 'Initialize' under 'Relationship' metaclass.

However, I can't figure how do I access ParentAttribute and ChildAttribute for a relationship for which I have created 'Initialize' event handler.

I'm new to PD and vbscript. So, I'm still trying to figure out how to use PD metamodel. Any kind of help is greatly appreciated. Thanks !

Regards,
Arvin

Accepted Solutions (1)

Accepted Solutions (1)

former_member200945
Contributor
0 Kudos

If you open a relationship's property, you can see Joins tab.

It has mapping information about parent attribute and child attribute.

We can use this mapping to automate FK data type change.

The algorithm is that if  parent attribute's data type is Serial, then change data type

from integer to Long integer in corresponding child attribute.

Here is an example:

Execute the following code. It reset customerID in businessOwner to Long integer.

Former Member
0 Kudos

Good Afternoon Philip,

Thank you so much for your help. I created an extension, added a 'model' metaclass and created an event handler 'OnModelSave', added your code sample there which will execute this script automatically everytime I save my model.

This is a work around for my problem and works perfectly fine. However, I was trying to change data type as soon as I create the reference. I guess I have to set up 'data type' at reference/relationship creation time and create reference with childattribute with datatype as long interger if parentattribute's datatype is 'serial'.

Thanks once again !

~Arvin

Answers (0)