cancel
Showing results for 
Search instead for 
Did you mean: 

Default columns when creating a table in PD16.0

Former Member
0 Kudos

We have several columns which are required in all tables. The columns are used for auditing. What is the process for configuring PD16.0 to automatically add these columns to table when created in the pdm of PD16.0?

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

arnaud_laurent
Employee
Employee
0 Kudos

I would create a new extension (select Model > Extensions), add the Initialize event handler to the Table metaclass and customize the Event Handler Script to have the column created automatically.

For example, edit your model extension you have created, right-click the Profile category to add the Table metaclass, right-click Table to add the Initialize event handler.

Select EXTENDEDDEFINITION_1::Profile\Table\Event Handlers\Initialize

and add this piece of script:

   dim mycol

   set mycol = obj.Columns.CreateNew

   mycol.name = "mycol_name"

   mycol.code= "mycol_code"

   mycol.comment = Now()

   mycol.datatype = "Integer"

   'and so on
 

It will be launched when you create a new table from the Toolbox, from the Browser, in a list or in a property sheet.

HTH

Arnaud

Former Member
0 Kudos

OK cool .. looks like VB script did figure out how to place the example in the extension properties.

Follow on question:

Where is the Columns object attributes listed at? Looked in the DBMS Properties  but did not see Columns but did see a Column and the attributes in the example where not there?

Additional .. seems like I would need some test to see the type of database so as not to supply an incorrect attribute for the database type in the PDM, Like Sybase / Oracle ? How could test for that?

Thanks

Ox

c_baker
Employee
Employee
0 Kudos

You could also model in one PDM (application level) and then use model-to-model generation and MDA to add the necessary columns to a PDM deployment model.

The benefit is that the transformation can handle model updates, etc.  You make changes to the first PDM and update the second.  New tables would get the additional columns but existing would be left alone, even if changes were made to them.

To handle database type differences, you could also do this in an LDM (generic datatypes) and let PD's conversions handle this when the PDM is generated.

Chris

arnaud_laurent
Employee
Employee
0 Kudos

In PowerDesigner, Select Help > Metamodel Objects Help columns to open the OLE help,

Type Column in the Index field, double-click Column and display "Column: Column (Library: PdPDM)".

You will get all properties, collections, etc. that you cna use for your VBS.

Rgds

Arnaud