Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9129

Re: Make PD generate DDL with desired FK index name

$
0
0

In DBMS, go to Script/Objects, click Reference. You will see predefined system variables

REFER is available. So it works for Reference.

If you click Index, it doesn't have REFER.

 

 

 

There are several way to achieve your goal.

But customizing DBMS is not a recommended because later on you will face migration issue when move to higher version.

 

 

 

 

First of all, create an extension in PDM:

extendatt.PNG

Now, if you bring up an index's property, click Extended Attributes tab, you will see entry indexName with empty value.

 

We want to use this variable to save desired index name.

Let's run an experiment:

You set My_index to indexName for an index. Save the change.

Go to Tools->Execute Commands->Edit/Run Script. Run the following code:

 

 

 

 

 

set model=ActiveModel

set tables=model.tables

for each t in tables

  set indexes=t.indexes

  for each ix in indexes

      if ix.getExtendedAttribute("indexName")<>"" then

         ix.code=ix.getExtendedAttribute("indexName")

         ix.name=ix.getExtendedAttribute("indexName")

      end if

  next

next

 

 

 

The index name is My_index.

 

 

 

Now the question becomes how can I get correct value for indexName?

 

 

If reference code is what you want, you can run the following code to collect the value.

 

set model=ActiveModel

set references=model.references

for each r in references

   output r.code

   'Save each r to vb object, say Dictionary.

  

next

 

 

 

Then you can call setExtendedAttribute for each index. This will set correct value for indexName.

 

 

 

Based on above code, you can create transformation.It'll automate the whole process.


Viewing all articles
Browse latest Browse all 9129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>