Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
sushantk19
Creator
Creator

Running sequence number while implementing SCD2

How to implement Running Sequence Number(Auto increasing) like Skey from SCD component.

 

Presently I have used the below logic:

Numeric.sequence("row1.id",1,1)

 

But this always start from 1 if i run my job again, causing duplicate in Skey values. Please suggest.

Labels (2)
1 Solution

Accepted Solutions
manodwhb
Champion II
Champion II

Use the one it will work ,what are you expecting.
Numeric.sequence("s1",1,1)

View solution in original post

10 Replies
manodwhb
Champion II
Champion II

Use the one it will work ,what are you expecting.
Numeric.sequence("s1",1,1)
sushantk19
Creator
Creator
Author

@manodwhb : Thanks! I will check that.

 

By the way, I used the postgresqlSCD component and worked perfectly fine for my requirement! Is there any issue with this component for implementing SCD2?

manodwhb
Champion II
Champion II

@sushantk19, You can implement SCD2 with postgresqlSCD component.

 

sushantk19
Creator
Creator
Author

Yes, It works fine!
sushantk19
Creator
Creator
Author

@manodwhb I got a issue here. Every time i run my job, sequence again starts from 1 and not as max(row count) in table. As an eg if i have 300 records in table with above sequence logic, the next time i load the data, the sequence no should be 301 and NOT 1 which is happening now. Please suggest what needs to be done here.

manodwhb
Champion II
Champion II

@sushantk19,in your job first you should read max value from that table keep in context or global variable and then in the next flow in the same job you need to connect both using on subjob ok and then you have to use a sequence like below .

 

Numeric.sequence("s1",context.max_id,1)

sushantk19
Creator
Creator
Author

Hi,

 

Sorry for the late reply again. This logic is failing and i am getting some random value as the next value.

I tested the code today again with some more data from source. My max id =10. I got a new code from the source, so this new code should be inserted with the id as 11, but i am getting sometimes as 23 or sometimes as 28. Not sure what is happening. Please note my code field is string and ID is integer.

 

ID= Integer

code= string.

 

whenever, a new code is found, it should increment the ID by 1.

Present logic is  ID=Numeric.sequence("s1",context.max_id,1), but its not working and giving me a random value as 23 or 28 after 10. please suggest what is going wrong here.

manodwhb
Champion II
Champion II

@sushantk19 , can you show your screenshot of mapping?

sushantk19
Creator
Creator
Author