One Star

Retrieving the last generated Sequence ID ....

I use Oracle sequence as Primary Key to insert data in Oracle table in my job...
In a subjob, I need to retrieve these data I just inserted in the parent job. To do that, I need to retrieve the generated sequence ID; How can I do that ?
Currently, I implemented a "workaround" query (see below).. But, doing this so, I have no guarantee to retrieve the good one (e.g. if several of the jobs are running at the same time, or DB used by others programs).
"select * from V2_OPERATIONS
where FK_FILEID = ( select Last_Number-1 from user_sequences where sequence_name = 'V2_FILEID' )
Using Oracle, we could use INSERT into ... values .... returning LAST_SEQ_ID . But how to implement such a thing in Talend ?
I would be happy to get our suggestions !
Community Manager

Re: Retrieving the last generated Sequence ID ....

Please see a related topic:
Let me know if you still have trouble.
Talend | Data Agility for Modern Business
One Star

Re: Retrieving the last generated Sequence ID ....

I read the case 8824... But, I think the problem remains for me.
My biggest problem is not to retrieve the last sequence number itself.... The problem is that I want to be sure that I get mine... because the table into which I insert data is not only used by Talend. Others programs (home made tools) can also do "INSERT' in this table during Talend job processing... And, in that case, I'm not sure to retrieve the sequence number that I used during the INSERT that happened during Talend job processing. That the reason I asked a way to retrieve to value returned by the Oracle statement INSERT into ... values ... RETURNING MY_SEQUENCE