首页 > 解决方案 > ODI 11g 逆向工程文件修改

问题描述

抱歉,如果这个问题有点过于宽泛,我经常使用逆向工程来读取 ODI 11g 中的 .TXT 文件。

我想知道是否有任何方法可以修改或创建 RKM(不确定这是否负责),默认情况下将列物理和逻辑长度分配为字符串数据类型的 300。

ODI 11g 分配的默认长度是 50。

有没有办法编辑这个?

标签: oracle-data-integrator

解决方案


您可以使用下一个 Groovy 脚本对物理长度和长度进行批量更改。

转到 ODI > Tools > Groovy > New Script 并复制粘贴下一个 Groovy 代码:

//Created by DI Studio
import ro.ns.odi.proxy.*
import oracle.odi.domain.model.*
import oracle.odi.domain.model.finder.*
import oracle.odi.domain.xrefs.expression.*
import oracle.odi.languages.support.*

IOdiEntityFactory odiFactory=OdiEntityFactory.createInstance(odiInstance)
IOdiBasicTemplate odiTemplate=odiFactory.newOdiTemplate()


String TABLE_NAME="SB_FINANCIALS_NEW_UU" //change with what you need
String MODEL_CODE="FILE" //change with what you need

odiTemplate.executeInTransaction{IOdiCommandContext ctx->

  IOdiEntityManager odiManager=ctx.getSupportingOdiInstance().getTransactionalEntityManager()
  IOdiDataStoreFinder dataStoreFinder=odiManager.getFinder(OdiDataStore)
  OdiDataStore dataStore=dataStoreFinder.findByName(TABLE_NAME,MODEL_CODE)

  assert dataStore!=null : "No data store was found. Please review the model code and data store name" 

  for (OdiColumn column:dataStore.columns){
     println "Analyzing column ${column.name} with type ${column.dataType.name}, length ${column.getLength()} and scale ${column.scale}"

     String dataTypeName=column.dataType.name

     column.fileFieldDescriptor.bytes=4000 //change with what you need
     //column.fileFieldDescriptor?.bytes=3000
     column.length=4000 //change with what you need
     column.dataType.name="String"

     switch(dataTypeName){
      case "String":
        //column.scale=2
        //column.fileFieldDescriptor?.decimalSeparator="x"
        println "--Column Modified"
      break
       case "Numeric":
        //column.scale=2
        //column.fileFieldDescriptor?.decimalSeparator="x"
        println "--Column Modified"
      break

    } 


  }
}

阅读 Groovy 代码并更改:

  • TABLE_NAME - 您需要更改数据类型的数据存储的名称;
  • MODEL_CODE - 来自 ODI > Models 的 MODEL 代码;
  • column.fileFieldDescriptor;
  • 列长度​​;
  • 列.数据类型。

推荐阅读