Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III

[resolved] Obtaining value of Oracle Sequence to use elsewhere

Hi all
I am having an issue attempting to insert into an Oracle table from a tMap and also then append that same row into a hash table for future use.  This means I don't have to select from the Oracle table to re-populate the hash.  The problem I have is that the key on the Oracle table is "ID" and is populated by a sequence via a database trigger (or using "Additional Columns" in the tOracleOutput component, both work).  I need this ID value to insert into the hash table as well as the rest of the data from the tMap.  My job is simple and looks like this:
Source Table --main--> tMap & Lookups --main--> Dest Table --main--> HashOutput  (Screen print provided)
Obviously my first port of call was Google however I do not seem to be able to get the detail I need to understand how I can get a sequence value per row prior to (sequence.NEXTVAL) or even after (sequence.CURRVAL) the insert into the destination table.
The following posts were either of no use or I cannot access the content of the attachments that shows me how the components such as tFlowToIterateor tjava have been really used:
https://community.talend.com/t5/Design-and-Development/resolved-How-to-use-Flowtoiterate/td-p/95069
https://community.talend.com/t5/Design-and-Development/resolved-Store-value-of-Oracle-Sequence-for-u...
https://community.talend.com/t5/Design-and-Development/Retrieving-the-last-generated-Sequence-ID/td-...
Would anyone be able to supply me with the detail I need to work out this small issue.  I am quite new to Talend and JAVA but am okay with the Oracle side of things.
Thanks very much
Craig
Talend Enterprise Data Integration Version 5.5.1
Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable

If you need the value from the sequence in your job you have to select this value before using it in the insert statement.
On way to do this is using simply a tOracleInput with a select on this sequence like
select my_seq.nextval from dual

This additional tOracleInput could be used in the tMap as lookup but with the lookup configuration "Load each row" instead of "Load once" (which is the default setting) and this tOracleInput should use an external connection to avoid connecting for each row.
It is simple and efficent and you have the sequence value at your finger tips 😉

View solution in original post

2 Replies
Anonymous
Not applicable

If you need the value from the sequence in your job you have to select this value before using it in the insert statement.
On way to do this is using simply a tOracleInput with a select on this sequence like
select my_seq.nextval from dual

This additional tOracleInput could be used in the tMap as lookup but with the lookup configuration "Load each row" instead of "Load once" (which is the default setting) and this tOracleInput should use an external connection to avoid connecting for each row.
It is simple and efficent and you have the sequence value at your finger tips 😉
_AnonymousUser
Specialist III
Author

Thanks, that worked perfectly and as you say totally simple!