Book a Demo

Author Topic: EA 12 - changes to DDL Create View template  (Read 4099 times)

hlampert

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
EA 12 - changes to DDL Create View template
« on: April 03, 2015, 01:36:13 am »
I'm  doing data modeling using EA 12 against the PostgreSQL DB platform.  I've created a view in the model using the Database Builder.  The view definition contains the SELECT statement for the view.  When I generate the DDL for this view to the DDL Execution Engine, the view doesn't get created - instead the generation script contains only the SELECT statement, instead of "CREATE VIEW <name> AS..." and the select statement.

 Looking at the DDL Create View Template  for PostgreSQL in the template editor, it seems that the template does *not* provide the CREATE VIEW statement.  I could modify the view definition titself to include "CREATE VIEW <name> AS" which would be easy, but if the name of the view changed I'd have to change it in the code, and that's what template generators are for!  So, I modified the DDL Create View template to include "CREATE VIEW $viewName AS" before the  $viewDefinition line and saved the template.  However, when I then generated the view, it still generated *only* the SELECT statement. It seemed to be ignoring my updated template,  which seems like a bug to me, or possibly I'm not doing something like linking the modified template to the "create view" action for the code generation engine.

Any input would be appreciated as I have many views to write and don't want to have to manage their names within the view definitions should they change.

Here's the modified DDL Create View template code:

%if ddlOptionGenerateView != "T"%
%endTemplate%

$viewName = %DDLName("EA", "VIEW", "INCLUDE_OWNER", "INCLUDE_SURROUND")%
$viewNameSS = %DDLName("EA", "VIEW", "INCLUDE_OWNER")%

$viewDefinition=%viewProperty:"DEFINITION"%

%EXECUTE_STRING($viewNameSS, "Create View", 530, $viewDefinition)%

CREATE VIEW $viewName AS
$viewDefinition

%PI("I", "")%
%DDLScriptSeparator%

%PI("I", "\n")%
%DDLTableLevelComment("VIEW")%
« Last Edit: April 03, 2015, 01:36:36 am by hlampert »

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: EA 12 - changes to DDL Create View template
« Reply #1 on: April 08, 2015, 12:37:23 pm »
Sounds like there could be a problem there.  Please send an official bug report and we will investigate further.

If possible, use this page: Registered User Bug Report.  Otherwise use: Unregistered Bug Report.

MMA

  • EA User
  • **
  • Posts: 63
  • Karma: +3/-0
    • View Profile
Re: EA 12 - changes to DDL Create View template
« Reply #2 on: April 15, 2015, 08:40:07 am »
Hi hlampert,

Actually, your modified script is quite close, but it will only take effect when you are generating to a sql file.

The script appearing in "DDL Execution Engine" is from function macro "EXECUTE_STRING".

So, following script works.  ;)

%if ddlOptionGenerateView != "T"%
%endTemplate%

$viewName = %DDLName("EA", "VIEW", "INCLUDE_OWNER", "INCLUDE_SURROUND")%
$viewNameSS = %DDLName("EA", "VIEW", "INCLUDE_OWNER")%

$viewDefinition="CREATE VIEW " + $viewName + " AS " + %viewProperty:"DEFINITION"%

%EXECUTE_STRING($viewNameSS, "Create View", 530, $viewDefinition)%
$viewDefinition

%PI("I", "")%
%DDLScriptSeparator%

%PI("I", "\n")%
%DDLTableLevelComment("VIEW")%
« Last Edit: April 15, 2015, 08:49:26 am by milesma »