cancel
Showing results for 
Search instead for 
Did you mean: 

How to change index columns using VBScript?

thiago_farias
Explorer
0 Kudos

Hi!

I need to remove incorrectly loaded data on expression of index columns.

I started the VBScript bellow but when the expression is altered to empty, the code is altered to empty too. Is there a way to change this?

Thanks in advance.

Set Mdl = ActiveModel

For Each t In Mdl.Tables
     'Indexes
    For Each i In t.Indexes
        
        For Each io In i.IndexColumns
            
            Dim auxValue, auxICol
            
            auxValue = Trim(io.Expression)
            
            If auxValue <> "" Then
                Output i.Code + "." + io.Code
                auxICol = io.Code
                io.Expression = ""
                ' Error
                'io.Code = auxICol
                'io.Delete
            End If
        Next
        
    Next
Next

 SAP PowerDesigner

Accepted Solutions (0)

Answers (1)

Answers (1)

Ondrej_Divis
Contributor
0 Kudos

Hi,

at first, always enter your PD version and in your case used definition file (DBMS) is also good to know. Not all definition files allow expressions in their indexes. I tested it with Oracle 19c definition file. Expression and Code of index column are connected. Name, Code and DisplayName are read-only attributes, i.e. you cannot modify them directly. You can modify only expression. What you enter into the expresssion, goes to the Code too. At least for Oracle 19c. What is the final goal you are trying to achieve by this? Perhaps there might be different way...

Regards,

Ondrej Divis

thiago_farias
Explorer
0 Kudos
Hi Ondrej!
thiago_farias
Explorer
0 Kudos
Hi Ondrej!
thiago_farias
Explorer
0 Kudos
Hi Ondrej! Really! When I change the expression, the code disapear. If I can't change this, turning only this field into null, then I need to delete the column with the expression and add it again with no expression. I'm using PD 16.5 with DBMS Properties of Oracle 11g (but I tested in recently versions with the same results). Thanks!
Ondrej_Divis
Contributor
0 Kudos
Hi Thiago, in index, you can either insert already existing columns from the parent table (use the "Add Columns" button in the toolbar) or you can insert your own IndexColumn which means you HAVE TO define its expression (which is then automatically replicated into the Code and DisplayName properties). Having your own IndexColumn without specifying the expression doesn`t make sense. In case you need more help on this topic (or other PD-related topics), please let me know. You can find me on LinkedIn too. Have a nice day, Ondrej Divis