简体   繁体   English

在Informatica中以序列生成的数字作为主键的表的更新策略

[英]Update strategy for table with sequence generated number as primary key in Informatica

I have a mapping that gets data from multiple sql server source tables and assigns a sequence generated number as ID for each rows. 我有一个映射,该映射从多个sql server源表获取数据,并为每行分配一个序列生成的数字作为ID。 In the target table, the ID field is set as primary key. 在目标表中,将ID字段设置为主键。

Every time I run this mapping, it creates new rows and assigns a new ID for the records that are pre-existing in the target. 每次我运行此映射时,它都会创建新的行,并为目标中预先存在的记录分配新的ID。 Below is an example: 下面是一个示例:

1st run:
ID   SourceID   Name   State
1     123        ABC   NY
2      456       DEF   PA

2nd run:
ID   SourceID   Name   State
1     123        ABC   NY
2      456       DEF   PA
3     123        ABC   NY
4      456       DEF   PA

Desired Output must: 1) create a new row and assign a new ID if a record gets updated in the source. 所需的输出必须:1)如果记录在源中得到更新,则创建一个新行并分配一个新ID。 2) create a new row and assign a new ID if new rows are inserted in the source. 2)如果在源中插入了新行,则创建一个新行并分配一个新ID。

How can this be obtained in Informatica? 如何在Informatica中获得它?

Thank you in advance! 先感谢您!

Give the ID field an IDENTITY PROPERTY ... ID字段一个IDENTITY PROPERTY ...

Create Table SomeTable (ID int identity(1,1), 
                        SourceID int, 
                        [Name] varchar(64), 
                        [State] varchar(64))

When you insert into it... you don't insert anything for ID. 插入时...您不会插入任何ID。 For example... 例如...

insert into SomeTable
select
   SourceID,
   [Name],
   [State]
from
   someOtherTable

The ID field will be an auto increment starting at 1 and increment by 1 each time a row is inserted. ID字段将是从1开始的自动递增,并且在每次插入一行时递增1。 In regards to your question about adding rows each time one is updated or inserted into another table, this is what TRIGGERS are for. 关于您的有关在每次更新或插入另一张表时添加行的问题,这就是TRIGGERS的目的。

I'll take a flyer and assume the ACTUAL question here is 'How can I tell if the incoming record is neither insert nor update so that I can ignore it'. 我将带一个传单,并假设这里的实际问题是“如何判断传入记录既不是插入也不是更新,以便我可以忽略它”。 You could 你可以

a) have some date field in your source data to identify when the record was updated and then restrict your source qualifier to only pick up records which were last updated after the last time this mapping ran... drawback is if fields you're not interested in were updated then you'll process a lot of redundant records a)在您的源数据中有一些日期字段,以标识记录何时更新,然后限制您的源限定符以仅选择上次运行此映射后最后更新的记录。缺点是如果您不输入字段感兴趣的人进行了更新,那么您将处理很多冗余的记录

b) better suggestion!! b)更好的建议! Configure a dynamic lookup which should store the latest state of a record matching by the SourceID. 配置动态查询,该查询应存储通过SourceID匹配的记录的最新状态。 Then you can use the newlookuprow indicator port to tell if the record is an insert, update or no change and filter out the no change records in a subsequent transformation 然后,您可以使用newlookuprow指示器端口来判断记录是插入,更新还是不更改,并在后续转换中过滤掉不更改记录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM