0

I am using Power Designer to create a database model. In one of my tables, I have created a Check constraint that calls a function to validate the attribute. The script for my table creation looks like this

   create table tbl_Inventory (
      Id      int                  identity,
      Name    VARCHAR(50)          not null
      constraint CK_Inventory_Name check (([dbo].[fn_CheckNameComplexLogic]([Name]) = 1)),
      constraint PK_Inventory primary key (Id),
   )

I have also created a function fn_CheckNameComplexLogic that performs the check.

When I try to use the code generation tool by going Database->Generate Database. The generated code always place create table before create function. Because my table depends on the function, the scripts always errors out. I could manually edit the generated code, but I am wondering if there is a place in PowerDesigner for configuring this.

Thanks for your help.

Wei Ma
  • 3,125
  • 6
  • 44
  • 72

2 Answers2

0

If may be a little overkill, but you can change the Generation Order to put (all) the functions (included in the Procedure category) before the Table.

  • embed the DBMS in your model with Database>Change Current DBMS
  • edit it with Database>Edit Current DBMS
  • change the order in the Script\Objects\GenerationOrder item (using the XML view)
  • put Procedure above Table
pascal
  • 3,287
  • 1
  • 17
  • 35
  • I've tried before to add a Tracibility Link from the Table to the "Procedure", but it did not change anything to the generation. – pascal Jun 06 '14 at 15:03
0

Simply add condition into Additional Checks of column properties tab after all constructs like %MINMAX% and %LISTVAL% and %CASE% and %RULES% and write here your condition ...

Andrew
  • 1