Pinned topicPluglet help - setting values in indexes

‏2013-01-10T21:32:17Z
|Tags:

Answered question
This question has been answered.

Unanswered question
This question has not been answered yet.

Hi,
I'm creating a pluglet to set the values for indexes to the desired values that our DBA's would prefer.
The reason I'm using a pluglet is to make the process more efficient and to ensure consistency.
Specifically, I'd like to set the values on the Partitions table in the properties view of an index (Primary Quantity (PRIQTY), Secondary Quantity (SECQTY), Free Page (FREEPAGE) and PCT Free (PCTFREE).
I can view the values if I do a toString on index.eContents()
e.g., here's a snippet of the toString(): ... primaryQuantity: 720, secondaryQuantity: 720, trackMod: false, freePage: 0, pctFree: 10, ...
Please someone, either point me towards code or documentation on how to set these 4 values. I think an EStructuralFeature may be involved but I'm not sure.
Thanks for the help!!!
Rob

Re: Pluglet help - setting values in indexes

If I understand right, you are going to change the index's attributes though Pluglet, right? I have following codes as an example to change the PCTFree, hope it helps.

//Firstly get the relevant attribute, the String PCTFree should strictly follow the ECore model definition.
EStructuralFeature feature = index.eClass().getEStructuralFeature("PCTFree");
//Use set command to update the value. Note: the new value should be integer for PCTFree,otherwise will return exception.
IDataToolsCommand cmd = CommandFactory.INSTANCE.createSetCommand("", index, feature, 10);
//At last, execute the command. You can also composite a few commands and execute in one transaction.
DataToolsPlugin.getDefault().getCommandManager().execute(cmd)

To get the attribute string, the easy way is to get it using from debugging index.eClass(), the attributes definition are meaningful and easy to pick out. See detail in the attachment.

Re: Pluglet help - setting values in indexes

If I understand right, you are going to change the index's attributes though Pluglet, right? I have following codes as an example to change the PCTFree, hope it helps.

//Firstly get the relevant attribute, the String PCTFree should strictly follow the ECore model definition.
EStructuralFeature feature = index.eClass().getEStructuralFeature("PCTFree");
//Use set command to update the value. Note: the new value should be integer for PCTFree,otherwise will return exception.
IDataToolsCommand cmd = CommandFactory.INSTANCE.createSetCommand("", index, feature, 10);
//At last, execute the command. You can also composite a few commands and execute in one transaction.
DataToolsPlugin.getDefault().getCommandManager().execute(cmd)

To get the attribute string, the easy way is to get it using from debugging index.eClass(), the attributes definition are meaningful and easy to pick out. See detail in the attachment.

Re: Pluglet help - setting values in indexes

If I understand right, you are going to change the index's attributes though Pluglet, right? I have following codes as an example to change the PCTFree, hope it helps.

//Firstly get the relevant attribute, the String PCTFree should strictly follow the ECore model definition.
EStructuralFeature feature = index.eClass().getEStructuralFeature("PCTFree");
//Use set command to update the value. Note: the new value should be integer for PCTFree,otherwise will return exception.
IDataToolsCommand cmd = CommandFactory.INSTANCE.createSetCommand("", index, feature, 10);
//At last, execute the command. You can also composite a few commands and execute in one transaction.
DataToolsPlugin.getDefault().getCommandManager().execute(cmd)

To get the attribute string, the easy way is to get it using from debugging index.eClass(), the attributes definition are meaningful and easy to pick out. See detail in the attachment.

The freePage value is not being updated.
I've tried to run the same code but substitute in pctFree for the parameter to the getEStructuralFeature call and I get a null pointer exception.
I guess what I was really hoping to find was a way of calling getters and setters for the following (primaryQuantity, secondaryQuantity, freePage & pctFree) (i.e., index.setFreePage(20)) but I doubt it's going to be that easy :).
If you have any more insights into how I could accomplish this task I would greatly appreciate your help!
Thanks!
Rob

The freePage value is not being updated.
I've tried to run the same code but substitute in pctFree for the parameter to the getEStructuralFeature call and I get a null pointer exception.
I guess what I was really hoping to find was a way of calling getters and setters for the following (primaryQuantity, secondaryQuantity, freePage & pctFree) (i.e., index.setFreePage(20)) but I doubt it's going to be that easy :).
If you have any more insights into how I could accomplish this task I would greatly appreciate your help!
Thanks!
Rob

I wasn't able to find the string "freePage", so I guess this might be the reason that your code doesn't work.

From the output, the PCTFree value could be set using this way. For the other properties, if they are not related to the features, maybe we can try some other ways,not sure if your model could be shared, that would be helpful to figure out the new ways.

I wasn't able to find the string "freePage", so I guess this might be the reason that your code doesn't work.

From the output, the PCTFree value could be set using this way. For the other properties, if they are not related to the features, maybe we can try some other ways,not sure if your model could be shared, that would be helpful to figure out the new ways.

Hi BM,
I appreciate your patience with me.
Here's the output of the code snippet you posted to list the features for the index selected.
***
eAnnotations; name; dependencies; description; label; comments; extensions; privileges; Schema; clustered; fillFactor; unique; systemGenerated; members; table; ForeignKey; includedMembers; indexType; busPeriodWithoutOverlap; DB2MultidimensionalIndex; padded; define; close; defer; copy; bufferPoolName; pieceSize; pieceSizeUnits; indexSpaceName; freePage; whereNotNull; erase; xmlPattern; asSQLDataType; compress; partitions; keyExpressions;
***
It's strange that my listing has the feature freePage listed and yours doesn't. Also, I'm not seeing in my listing other items within the Partitions tab for the properties of an Index that I'd like to set (e.g., Primary Quantity, Secondary Quantity nor am I seeing PCT Free which you have). So I'm unsure how to access these features.
What I was hoping would be a simple task has turned out to have burned too much time at this point (common theme for me and IDA).
I need a similar type of functionality to update the properties of tablespaces. I'll turn my attention there to see if I glean any additional insights.
Thanks for your time!
Rob

Re: Pluglet help - setting values in indexes

Hi BM,
I appreciate your patience with me.
Here's the output of the code snippet you posted to list the features for the index selected.
***
eAnnotations; name; dependencies; description; label; comments; extensions; privileges; Schema; clustered; fillFactor; unique; systemGenerated; members; table; ForeignKey; includedMembers; indexType; busPeriodWithoutOverlap; DB2MultidimensionalIndex; padded; define; close; defer; copy; bufferPoolName; pieceSize; pieceSizeUnits; indexSpaceName; freePage; whereNotNull; erase; xmlPattern; asSQLDataType; compress; partitions; keyExpressions;
***
It's strange that my listing has the feature freePage listed and yours doesn't. Also, I'm not seeing in my listing other items within the Partitions tab for the properties of an Index that I'd like to set (e.g., Primary Quantity, Secondary Quantity nor am I seeing PCT Free which you have). So I'm unsure how to access these features.
What I was hoping would be a simple task has turned out to have burned too much time at this point (common theme for me and IDA).
I need a similar type of functionality to update the properties of tablespaces. I'll turn my attention there to see if I glean any additional insights.
Thanks for your time!
Rob

I think the differences come from different index instance. I am using org.eclipse.datatools.modelbase.sql.constraints.Index, and the index instance is LUWIndex, so may I know your DB's vendor, or what kind of the instance you got?

Re: Pluglet help - setting values in indexes

I think the differences come from different index instance. I am using org.eclipse.datatools.modelbase.sql.constraints.Index, and the index instance is LUWIndex, so may I know your DB's vendor, or what kind of the instance you got?