Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ea0818

Pages: [1]
1
Yes, the language, macros and syntax rules used in the transform templates are not easy to work with. I found it quite frustrating. Something as simple as combining an "if" with a math operation (e.g. %if $a == Math_Add(2, 3)%) is not allowed.

But I started with the transform templates that were supplied, and made fixes and enhancements. And at this point, it will be far less work to just add to the existing templates than to re-write everything in another language.

Anyone know a way to do a for...next loop in the transform templates?

2
I need to do a loop in a transform template. For example a for...next or a while loop.

I found the EA documentation for the macros at https://sparxsystems.com/enterprise_architect_user_guide/15.2/model_domains/macros.html
In particular branching, such as if or elseIf, is found at https://sparxsystems.com/enterprise_architect_user_guide/15.2/model_domains/branching_macros.html

But I don't see any macro for repeating a set of instructions. Best I can think of is to write a custom transform template, and then repeatedly call it from the main transform template. One of the parameters would indicate what iteration in the loop is to be processed during this execution.
This would be an ugly solution though, as I would need to repeat the call (from the main template) as many times as needed, such as:
$remark="Perform the ten iterations"
%DoLoopWork(1)%
%DoLoopWork(2)%
%DoLoopWork(3)%
%DoLoopWork(4)%
%DoLoopWork(5)%
%DoLoopWork(6)%
%DoLoopWork(7)%
%DoLoopWork(8)%
%DoLoopWork(9)%
%DoLoopWork(10)%


Anyone have a better idea?

3
General Board / Re: Create MySQL table with FLOAT and DOUBLE PRECISION
« on: September 24, 2020, 05:26:54 am »
I think your intention is to have EA generate only FLOAT, rather than FLOAT(0).

In your code, you have the same code for both float and other types.

%if $LENGTH != "" and $LENGTH != "0"%
(
$LENGTH
)
%elseIf $LENGTH != "" and $LENGTH == "0" and ($Type=="FLOAT" or $Type=="DOUBLE")%
(
$LENGTH
)
%endIf%


Try using the following instead, see what happens.

%if $LENGTH != "" and $LENGTH != "0"%
(
$LENGTH
)
%elseIf $LENGTH != "" and $LENGTH == "0" and ($Type=="FLOAT" or $Type=="DOUBLE")%
$remark = "Do not add anything to the data type; having (0) is a problem"
%endIf%


No promises that the syntax is correct.
Also, are you sure you are editing the correct place?  My guess is that the code
(
$LENGTH
)
would give text like "(0)", but you are reporting that you are receiving "(0,0)".  I suggest deliberately adding some text like "my change here" so that you can then look at the generated DDL script and confirm that you are altering the correct spot in the script.

4
General Board / Re: Create MySQL table with FLOAT and DOUBLE PRECISION
« on: September 22, 2020, 05:48:34 am »
You need to edit the script used to create the DDL commands.

I have a similar problem, with EA creating datetime2(0) datatypes incorrectly in SQL Server (MSS).  Here is the documentation that shows how to fix my issue; you will need to do something similar.


Problem:  In the column properties, when user sets the data type to datetime2 and a length of 0, EA is generating a create-table DDL script that gives the datatype of “datetime2”, not “datetime2(0)”.

In Microsoft SQL Server, the datatypes datetime2(0) and datetime2 are not the same.  (The number in “datetime2(#)” specifies precision, which is 0 to 7 digits, with an accuracy of 100ns. The default precision is 7 digits.)
The following script gives the results shown below.
declare @d1 datetime2(7)
       ,@d2 datetime2(0)
       ,@d3 datetime2

select @d1 = GETDATE()
      ,@d2 = GETDATE()
      ,@d3 = GETDATE()

select @d1 as 'datetime2(7)'
      ,@d2 as 'datetime2(0)'
      ,@d3 as 'datetime2'

datetime2(7)                  datetime2(0)               datetime2
---------------------------   ------------------------   ---------------------------
2018-08-08 14:49:21.1300000   2018-08-08 14:49:21        2018-08-08 14:49:21.1300000

It is therefore necessary to generate DDL statements for SQL Server that specify “datetime2(0)” when the user specifies a length of 0.  Enterprise Architect is generating “datetime2” however.
All generated DDL scripts would therefore need to be corrected before use.


Solution:  It is necessary to open the “DDL Template Editor” tab, to change the scripts used to generate DDL statements.

EA14:  Use Code \ Schema \ DDL \ Edit the DB Schema (DDL) Templates.

EA15:  In the Find Command bar above the ribbon, type  “DDL”, and chose Template; this opens the “DDL Template Editor” tab.

Select the “DDL Data Type” value from the template drop down if available.
Select the required database type from the Language drop down if available.
Sort results by clicking the Name column header.
Select the “DDL Column Definition” template.
Modify the code starting about line 10, as shown below.  Since the templates appear to be specific to the Language (e.g. SQL Server 2012), this should not affect models for other databases.  It will be necessary to make this correction in every EA project file.

%if $Size=="1"%
$LENGTH = %columnProperty:"LENGTH"%
%if $LENGTH != "" and $LENGTH != "0"%
(
$LENGTH
)
$remark = "2018-08-15 Modification by Dale Fox"
$remark = "This elseIf block fixes the generation for datetime2(0)"
$remark = "data types for SQL Server"
%elseIf $LENGTH != "" and $LENGTH == "0" and $Type=="datetime2"%
(
$LENGTH
)
%endIf%


Click Save.

5
And a couple questions about cross-reference tables. 
In my Domain Model I have a relationship between two classes; I'll use the example of Student and Course.  The relationship between these classes has multiplicity of 0..* on both sides. 
When doing the transform to DDL, EA therefore needs to create a cross-reference database table, StudentCourse.  StudentCourse lives between the two database tables of Student and Course.  EA correctly adds two columns to StudentCourse; these are used to provide the Foreign Key from that cross reference table to the Primary Key ID column in the two other tables; i.e. column StudentID is used for the FK to Student and CourseID is used for the FK to Course.

Problem 1:  EA is creating the two columns in the StudentCourse cross-reference table with "not null" set to false; but "not null" should be true for both columns in the StudentCourse cross-reference table.  You will only create a record in this cross-reference table when you are linking a Student to a Course, so both columns should be mandatory.  See settings for connection between the domain classes below.

Problem 2:  EA is not adding a Primary Key to this StudentCourse cross-reference database table.  The PK should be the two columns.  See settings for connection between the domain classes below.


I think I have correctly modeled the classes and their relationship in the Domain model; in the Association Properties dialog for the relationship, in the Role(s) section, I have the following values for both sides of the relationship:
Multiplicity:  0..*
Ordered:  False
Allow Duplicates:  False  (if this was true, then I would understand Problem 2 above)
Stereotype:  (blank)
Alias:  (blank)
Access:  Public
Navigability:  Unspecified
Aggregation:  none
Scope:  instance
Constraints:  (blank)
Qualifiers:  (blank)
Member Type:  (blank)
Changeable:  none
Containment:  Unspecified
Derived:  False
Derived Union:  False
Owned:  False

Thank you for any assistance.

6
I have a Business Domain Model, that has the classes, with their attributes and relationships.

I can use Ribbon - Design - Tools - Transform - Apply Transformation.  This creates or synchronizes database tables in a Database model in the EA project.

I need to make some changes to how EA transforms the classes to the database tables.  I have been able to make several changes in the Transformation scripts for the DDL language, but there are a couple things I do not see how to accomplish.

1)  How do I set a default value for the Owner value in created database tables?  E.g., in the properties for the database table, choose Table Detail tab, and see the Owner field.  I want the default Owner for all tables to be "dbo".

2)  How do I change the Transform template scripts so that, in the generated database table, the PK column will be first, followed by any FK columns, lastly followed by the columns created from the attributes of the source class?  I tried editing the Class script to move the Primary Key code before the line with %list="Attribute" @separator="\n" @indent="  "%, but it had no effect.

Is there somewhere that I can find documentation for all destination-class tags that are supported by EA?  For example, I should be able to find documentation for whatever code I need to include in my Transformation DDL script to set the Owner tag for the destination database table.

Thanks.

7
Bugs and Issues / Re: SqlServer 2012 Schema support
« on: February 26, 2019, 04:23:26 am »
To have the script include the schema owner / db owner:  On the Tags tab, set OWNER to required value, not Tablespace

Pages: [1]