Live Database Reverse Engineering

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.

The following queries are used in live reverse engineering:
Note: You can also create your own queries (see Creating Queries to Retrieve Additional Attributes).

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.

For example, the SqlListQuery in the View category of Oracle 11g R1 extracts values for eight variables:
{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:

Example: Using ID to Define the Identifier

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.

Example: Converting Value Pairs

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