Document directory
- Copy attribute name to definition using macros in ER/studio
Copy attribute name to definition using macros in ER/studio
Recently, when processing the SQL script generated by ER/studio, we found that if the definition is not defined, there will be no table and field comments after the SQL script is generated.
Therefore, a macro is written to implement this function. The Code is as follows:
Save the following code as XXX. put the bas file in the macros folder under the ER/studio installation directory, and ER/studio can be automatically loaded to the macros tab, for example, c: \ Program Files \ Embarcadero \ erstudio6.5 \ macros
Dim entcount as integer Dim colcount as integer Dim mydigoal as digoal Dim mymodel as Model Dim myentity as entity Dim myattribute as attributeobjdim tablearray () as string Dim colarray () as string Function getcolumns (tablename as string) Dim indx as integer Dim count as integer Count = 1 Indx = 0 Set myentity = mymodel. Entities. Item (tablename) Colcount = myentity. Attributes. Count Redim colarray (0 to colcount) as string For Count = 1 to colcount For each myattribute in myentity. Attributes If myattribute. sequencenumber = count then If mymodel. Logical = true then If myattribute. haslogicalrolename = true then Colarray (indx) = myattribute. logicalrolename Else Colarray (indx) = myattribute. attributename End if Else If myattribute. hasrolename = true then Colarray (indx) = myattribute. rolename Else Colarray (indx) = myattribute. columnname End if End if Myattribute. Definition = colarray (indx) Indx = indx + 1 End if Next myattribute Next countEnd Function Sub main Debug. Clear Set mydigoal = diagrammanager. activedigoal Set mymodel = mydiworkflow. activemodel Dim indx as integer Indx = 0 Entcount = mymodel. Entities. Count-1 Redim tablearray (0 to entcount) as string For each myentity in mymodel. Entities If mymodel. Logical = true then Tablearray (indx) = myentity. entityname Else Tablearray (indx) = myentity. tablename End if Myentity. Definition = tablearray (indx) Getcolumns (tablearray (indx )) Indx = indx + 1 Next myentity End sub |