PowerDesigner can reverse engineer from a live database connection into a PDM. The queries that control live reverse engineering are available in the Script/Objects category.
Each type of query has the same basic structure comprised of a comma-separated list of PowerDesigner variables enclosed in curly braces { } followed by a select statement to extract values to populate these variables. The values of the returned records are stored in these variables, which are then committed as object attribute values.
{OWNER, VIEW, VIEWSTYLE, ExtObjViewType, ExtObjOIDList, ExtObjSuperView, XMLSCHEMA EX, XMLELEMENT EX} select v.owner, v.view_name, decode (v.view_type, 'XMLTYPE', 'XML', 'View'), v.view_type, v.oid_text, v.superview_name, decode (v.view_type, 'XMLTYPE', '%SqlXMLView.'||v.owner||v.view_name||'1%', ''), decode (v.view_type, 'XMLTYPE', '%SqlXMLView.'||v.owner||v.view_name||'2%', '') from sys.all_views v [where v.owner = %.q:SCHEMA%]
Each comma-separated part of the header may contain the following:
Name of variable - [required] can be any standard PDM variable (see PDM Variables and Macros), metamodel public name (see Metamodel Concepts) or the name of an extended attribute defined under the metaclass in the Profile (see Profile Category (DBMS)).
ID - [optional] the variable is part of the identifier.
... - [optional] the variable must be concatenated for all the lines returned by the SQL query that have the same values for the ID columns. The ID and ... (ellipsis) keywords are mutually exclusive.
Value pairs - [optional] lists conversions between retrieved values and PowerDesigner values in the following format (where * means all other values):
(value1 = PDvalue1, value2 = PDvalue2, * = PDvalue3)
In this script, the identifier is defined as TABLE + ISKEY+ CONSTNAME through the use of the ID keyword:
{TABLE ID, ISPKEY ID, CONSTNAME ID, COLUMNS ...} select t.table_name, 1, null, c.column_name + ', ', c.column_id from systable t, syscolumn c where etc..
In the resulting lines returned by the SQL script, the values of the fourth field are concatenated in the COLUMNS field as long as these ID values are identical.
SQL Result set Table1,1,null,'col1,' Table1,1,null,'col2,' Table1,1,null,'col3,' Table2,1,null,'col4,' In PowerDesigner memory Table1,1,null,'col1,col2,col3' Table2,1,null,'col4'
In the example, COLUMNS will contain the list of columns separated by commas, and PowerDesigner will process the contents to remove the last comma.
In this example, when the SQL query returns the value 25 or 26, it is replaced by JAVA in the TYPE variable:
{ADT, OWNER, TYPE(25=JAVA , 26=JAVA)} SELECT t.type_name, u.user_name, t.domain_id FROM sysusertype t, sysuserperms u WHERE [u.user_name = '%SCHEMA%' AND] (domain_id = 25 OR domain_id = 26) AND t.creator = u.user_id