oracle-data-integrator - ODI 11g 逆向工程文件修改
问题描述
抱歉,如果这个问题有点过于宽泛,我经常使用逆向工程来读取 ODI 11g 中的 .TXT 文件。
我想知道是否有任何方法可以修改或创建 RKM(不确定这是否负责),默认情况下将列物理和逻辑长度分配为字符串数据类型的 300。
ODI 11g 分配的默认长度是 50。
有没有办法编辑这个?
解决方案
您可以使用下一个 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;
- 列长度;
- 列.数据类型。
推荐阅读
- angular - 在 mat-nav-list 组件中显示单击的列表项值
- android - 使用 mediamuxer 合并 H.264 视频流和 AAC 音频流,但无法播放合并的 mp4 视频
- javascript - 返回由 promise.all() 填充的数组
- cabal - > 阴谋安装。不在公司网络上时出现“读取本地包时出错”(Win 10)
- wordpress - 地理编码不成功,原因如下:ZERO_RESULTS
- javascript - 如何在 angularjs 中创建输入格式属性指令?
- laravel - laravel vue 插件使用方法
- ios - 应用程序的更新版本未反映在设置的应用程序列表中,但应用程序正在更新
- node.js - 使用 express-validator 自定义验证器验证两个字段
- eiffel - Eiffel:“埃菲尔”库和图案库有什么区别?