Book a Demo

Author Topic: Database Datatype aliases  (Read 2750 times)

greentea

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Database Datatype aliases
« on: March 03, 2009, 08:27:56 pm »
Hi there!
we're evaluating EA, and currently looking for a feature we're used to use in CASE Studio when working on the DB Data Model:
Is it possible to define custom "alias" types for a column?
For example, we define "PARTNUMBER" as custom type, but then want to transform "PARTNUMBER" to a standard type when generating the DDL.
The idea is to be able to define/redefine the "PARTNUMBER" exact type later in the project, and have all "PARTNUMBER" typed fields updated automatically.

I see there is a cross-database-datatypes-mapping stuff, but am not sure that's the suggested way to achieve this... basically we only work with Oracle.
I also saw the "Transformation editor"... should I code something there? Had a look at the manual but it still looks quite cryptic to me :-(


Thanks in advance for any inputs, and have a nice day ;-)

greentea

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Database Datatype aliases
« Reply #1 on: March 06, 2009, 08:22:17 pm »
Hello,

herebelow the solution I found for now; not the most elegant in my opinion, but at least it works.

Should anyone have a better solution... let me know ;-)

STEP 1:

Create new Transformation Template for DDL language:
Type: <none>
Name: DataType_Aliases

Content:
Code: [Select]
%attType == "PRODTYPE" ? "VARCHAR(11)"%
%attType == "PRODREF" ? "VARCHAR(6)"%
%attType == "PRODID" ? "VARCHAR(6)"%

Basically you list there all your custom datatype conversion needs in that ugly format :-) Your alias on the left side (here "PRODTYPE", "PRODREF",... ), the wished translation on the right.

STEP 2:
Update the DDL -> Attribute template as follows:

Code: [Select]
Column
{
  %TRANSFORM_CURRENT("type", "stereotype", "collection", "constant", "containment", "ordered", "static", "volatile")%
  $DTA=%DataType_Aliases()%
  %if $DTA!=""%
     type=%qt%$DTA%qt%
  %else%
     type=%qt%%CONVERT_TYPE(genOptDefaultDatabase,attType)%%qt%
  %endIf%
}

Here it calls the macro with the mappings, and if he founds a match the thing gets replaced, else we stay with the original attType(= Column datatype) procedure.

STEP 3:
Now when you call "Transform current package" on your data model package, and select DDL as output... magic happens.

Any better idea welcome ;-)

Cheers.
« Last Edit: March 06, 2009, 09:27:36 pm by greentea »

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: Database Datatype aliases
« Reply #2 on: April 23, 2009, 05:26:23 pm »
Quote

herebelow the solution I found for now; not the most elegant in my opinion, but at least it works.

Should anyone have a better solution... let me know ;-)
[...]
Any better idea welcome ;-)


I am popping this up- we have the same problem but with 750 custom datatypes this is not the way to go.

Anybody had any better ideas?

Oliver