Book a Demo

Author Topic: DDL Transformations and datatypes  (Read 3426 times)

lgozalvez

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
DDL Transformations and datatypes
« on: May 09, 2007, 01:50:49 am »
It's possible to configure the datatype destination in every attribute when i transform a model into DDL model?

For example, i have a Class "Person" with an attribute called "Name", the type is (C# mode) "string". When i transform the class to DDL model, the default template, create a class called "Person" with an attribute called "Name" but the type is (in sqlserver 2000) "Text". I need to change this for a "varchar(250)" type. Is this possible?

I know the line that applies the model to model transformation (in the Class DDL Template) in this case, but I don’t know how to configure the “genOptDefaultDatabase”:

language=%qt%%genOptDefaultDatabase%%qt%
%list="Attribute" @separator="\n" @indent="  "%

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: DDL Transformations and datatypes
« Reply #1 on: May 09, 2007, 01:34:31 pm »
genOptDefaultDatabase is the default database set up for the current EA model.  There are various places this can be set including the code generation toolbar.

If you want to be more specific about the datatypes written be the transformation you will need to override the behaviour of the CONVERT_TYPE macro to generate the types you want.

eg.
Code: [Select]
%if attType=="Integer"%
 type="int"
%elseIf attType=="String"%
 type="varchar"
 length="250"
%endIf%


If you need to have strings of both text and varchar type then you will need to record this in the PIM in some way such as a tagged value and use this in your transformation.

eg.
Code: [Select]
%if attType=="Integer"%
 type="int"
%elseIf attType=="String" and attTag:"maximumCharacters" != ""%
 type="varchar"
 length=%qt%%attTag:"maximumCharacters"%%qt%
%elseIf attType=="String"%
 type="text"
%endIf%