Add auto generate Data to postgreSQL

Six Stars

Add auto generate Data to postgreSQL

Hi

I have a problem with data of a tFileInputDelimited. 

my Job looks like: 
tFileInputDelimited -->tJava--> tJavaRow_1-->tMap-->tDBOutput_2

 

The CSV file I read had seperate cloumns like column1, column2 etc

I only need column1 and column2 , in column1 only a number like 12345 in column2 are numbers delimited by , --> 1234,5678 (the entry for that field is varaiable)
I write a script what split the column2, so I generate a incremtor for an ID in Database and set it to a primaryKey

//SplitingChild and connect to master for Table

String pzn = input_row.PZN;
String childPzns = input_row.CHILD_PZN;
String childPzn = "";
String childPZNout = "";

    	 //System.out.println("testout: " + test);
    	 if(childPzns != null && !childPzns.isEmpty()){
    	 
    	 String[] splittChildPZNs = childPzns.split("\\,");
    	 
    		 for (String childPZN : splittChildPZNs) {
    		 		i++;
            		System.out.println("PZN:  "+ pzn +" --> ChildPzn --> " + childPZN + " --> ID: " + i);
            		globalMap.put("pzn", pzn);
            		globalMap.put("childPzn", childPZN);
            		globalMap.put("id", i);
            		
            		 
            	 }
             
    	 } else {
    	 			i++;
            	 	System.out.println("PZN:  "+ pzn + " --> ID: " + i);
            	 	globalMap.put("pzn", pzn);
            		globalMap.put("childPzn", "");
            		globalMap.put("id", i);
            	 	
    	}

if I use the globalMap vars in tMap 
job1.PNG

it only write the pzn, childpzn and id, for the number of line out of the tFileInput.
In my tLog it shows correct :


PZN: 01364773 --> ChildPzn --> 01364804 --> ID: 18224
PZN: 01364773 --> ChildPzn --> 01364796 --> ID: 18225

It only writes the last input with the ID 18225 and the input with the ID 18224 was ignored. 

Thanks for yout help :-) 

best regards Chris




Accepted Solutions
Highlighted
Six Stars

Re: Add auto generate Data to postgreSQL

Thanks your for fast answer, 

and it is possible with a routine, tLibraryLoad, tJavaRow and java postgreSQL code connection. 

I connect to the Database via postgreSQL driver and loop some Data to the Database. So I solved the Problem and use a ETL Tool with JAVA Smiley Wink

regards Chris 


All Replies
Twelve Stars

Re: Add auto generate Data to postgreSQL

your cannot use an etl as an java tool!
Talend data are in row not in globlaMap.
globalMap are to retrieve components data.
Context to set parameters to the job.

in you case you want to normaliz data so you can use tNormalize.

ones you have select tNormalize on Your Job Press F1 to have a sample.

Good luck.

Francois Denis

Tag as "solved" for others! Kudos to thanks!

Highlighted
Six Stars

Re: Add auto generate Data to postgreSQL

Thanks your for fast answer, 

and it is possible with a routine, tLibraryLoad, tJavaRow and java postgreSQL code connection. 

I connect to the Database via postgreSQL driver and loop some Data to the Database. So I solved the Problem and use a ETL Tool with JAVA Smiley Wink

regards Chris 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog