Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Alpha549
Creator II
Creator II

Know if a row is inserted into a database or updates a row of that database

Hello world !

I'm using a tOracleOutput set on Update or Insert.

I would like to know if a row is actually inserted into the database, or if it updates.

I've thought about a solution : check first if this row is in the targeted table making an inner join and getting rejected = this row will be inserted, else it's an update.

However, I would like to know there is a built-in method to know that ?

Thanks in advance ! 🙂

Labels (2)
4 Replies
MShakir
Contributor
Contributor

Hi,

I am exploring TOS since a week...

Hope this code helps...

 

[1] Put below code in tJava component code:

System.out.println("Inserts: " + ((Integer)globalMap.get("tDBOutput_1_NB_LINE_INSERTED")));

System.out.println("Updates: " + ((Integer)globalMap.get("tDBOutput_1_NB_LINE_UPDATED")));

System.out.println("Deletes: " + ((Integer)globalMap.get("tDBOutput_1_NB_LINE_DELETED")));

 

[2] DBOutput (Trigger) On Component Ok - Link to tJava_1 component

Monster971
Contributor
Contributor

Thanks for the quick response, it's super helpful.

But if I want to have this output format (with data from my columns):

INSERT: id1, XXX, XXX

INSERT: id2, XXX, XXX

UPDATE: id3, XXX, XXX

INSERT: id4, XXX, XXX

UPDATE: id5, XXX, XXX

 

How to adapt the Java code in the T_Java?

Alpha549
Creator II
Creator II
Author

Thank you MShakir, NB_LINE_INSERTED / UPDATED / DELETED are AFTER component global var. Not sure they are available if the whole stream of data is not finished. They are integers, not related to the data, to be able to retrieve IDs and other columns.

MShakir
Contributor
Contributor

Hi,

Yes, even I could't find any component with such functionality.

Go by your proposed solution, it works...