Informatica 如何使用DB的Sequence。

来源:互联网 发布:java什么书比较好 编辑:程序博客网 时间:2024/04/27 15:35

查询了网上如下建议:

You need to create a function in database that accept sequence name as parameter and return the sequence value. 


Create a stored procedure transformation with two ports. 
1) Sequence Name as Input Port 
2) Return Value as Output Port 

Provide database function name (along with schema name) in "Stored Procedure Name" on Properties tab. 

Call the stored procedure transformation from expression transformation. 

:SP.storedproc(seq_name) 


但是使用informatica自己的sequence generator是效率最高的。

最常用的方法就是获得记录的最大的序号,然后+1.

Informatica sequence generator中两个选项的作用:

Cycle与Reset,这两个选项的作用都是为了使序列号不会因到达最大值而产生错误。而它们却有不同的作用。
Cycle是指循环使用序列号,当序列号当前值到达最大值时,重置序列号为初始值,当然这样会造成实际的序列号重复,只有当系统对此没有特别限制时,可以使用。
Reset则是指在每运行完一次后,序列号自动重置为初始值,这更大程度上产生同样的序列号,但这个选项却有它很大的用处,例如对同一批次数据需要产生一个序列号,每匹次均从初始值开始编号,此选项即显得非常的有用了。还有对于每次加载目标表,目标表需要清空数据,而目标表由一个Sequence作为主键的,此时可以选中该选项为其产生序列号。