<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Insert multiple unique records into MySQL in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298757#M71182</link>
    <description>Removing the unique key would allow for the insert but I would like to know how to go about solving the problem by using a rountine to update the name column. 
&lt;BR /&gt;How do I go about getting the rountine to run the query above and pass through the &amp;lt;current name&amp;gt;? The &amp;lt;current name&amp;gt; will be based on the current row being mapped, so I can't create a SQLInput for it. 
&lt;BR /&gt;Thanks</description>
    <pubDate>Wed, 02 Jun 2010 12:57:06 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2010-06-02T12:57:06Z</dc:date>
    <item>
      <title>Insert multiple unique records into MySQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298755#M71180</link>
      <description>I have a MySQL input (Table 1) with a field which I am mapping to a unique field. 
&lt;BR /&gt;The input field contains duplicate values for the input, which can not be saved to the table (Table 2) due to MySQL duplicate error message.
&lt;BR /&gt;What I am trying to do is when an insert fails alter the input value and try the insert again.
&lt;BR /&gt;For example the output for an input is:
&lt;BR /&gt;
&lt;PRE&gt;Table 1 input:&lt;BR /&gt;id name&lt;BR /&gt;1  abc&lt;BR /&gt;2  xyz&lt;BR /&gt;3  abc&lt;BR /&gt;4  efg&lt;BR /&gt;5  abc&lt;BR /&gt;6  abc&lt;BR /&gt;Table 2 output:&lt;BR /&gt;id name&lt;BR /&gt;1  abc&lt;BR /&gt;2  xyz&lt;BR /&gt;3  abc#1&lt;BR /&gt;4  efg&lt;BR /&gt;5  abc#2&lt;BR /&gt;6  abc#3&lt;/PRE&gt;
&lt;BR /&gt;I have looked at tLoop as a while loop but not sure how I use a condition of not inserted based on a MySQL query.
&lt;BR /&gt;I am using the following query to find the next # value, where &amp;lt;current name&amp;gt; is the value in 'Table 1 name', e.g. abc
&lt;BR /&gt;
&lt;PRE&gt;select count(*) from table 2 where name regex '&amp;lt;current name&amp;gt;#+$'&lt;/PRE&gt;
&lt;BR /&gt;Which tells me what the next # value should be, but putting this all together into a job using a tMap has me scratching my head.
&lt;BR /&gt;Am I trying to do the impossible?</description>
      <pubDate>Sat, 16 Nov 2024 13:24:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298755#M71180</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T13:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Insert multiple unique records into MySQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298756#M71181</link>
      <description>Hi
&lt;BR /&gt;Can't you remove the key on the name column ?
&lt;BR /&gt;You should be able to insert duplicate values.
&lt;BR /&gt;
&lt;BR /&gt;In case that doesn't solve your problem : 
&lt;BR /&gt;Create a routine that checks if the value exists then returns the formatted value (MyRoutine.check(myString) = "myString#X"). Use this routine on the "name" column.
&lt;BR /&gt;And the "next" value can be stored in a file/db, this should make it easier to get. 
&lt;BR /&gt;
&lt;BR /&gt;Regards,
&lt;BR /&gt;Lie</description>
      <pubDate>Tue, 01 Jun 2010 10:40:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298756#M71181</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-06-01T10:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Insert multiple unique records into MySQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298757#M71182</link>
      <description>Removing the unique key would allow for the insert but I would like to know how to go about solving the problem by using a rountine to update the name column. 
&lt;BR /&gt;How do I go about getting the rountine to run the query above and pass through the &amp;lt;current name&amp;gt;? The &amp;lt;current name&amp;gt; will be based on the current row being mapped, so I can't create a SQLInput for it. 
&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 02 Jun 2010 12:57:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298757#M71182</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-06-02T12:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Insert multiple unique records into MySQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298758#M71183</link>
      <description>&lt;PRE&gt;package routines;&lt;BR /&gt;import java.util.HashMap;&lt;BR /&gt;import java.util.Map;&lt;BR /&gt;public class SNumeric {&lt;BR /&gt;    private static final Map&amp;lt;String, Integer&amp;gt; seq_Hash = new HashMap&amp;lt;String, Integer&amp;gt;();&lt;BR /&gt;    private static final Map&amp;lt;String, Map&amp;lt;String,Integer&amp;gt;&amp;gt; key_Hash = new HashMap&amp;lt;String, Map&amp;lt;String,Integer&amp;gt;&amp;gt;();&lt;BR /&gt;    /**&lt;BR /&gt;     * return the value corresponding to the key or an incremented numeric id&lt;BR /&gt;     * &lt;BR /&gt;     * {talendTypes} int | Integer&lt;BR /&gt;     * &lt;BR /&gt;     * {Category} Numeric&lt;BR /&gt;     * &lt;BR /&gt;     * {param} string("s1") sequence identifier&lt;BR /&gt;     * &lt;BR /&gt;     * {param} string("key") key&lt;BR /&gt;     * &lt;BR /&gt;     * {param} int(1) step&lt;BR /&gt;     * &lt;BR /&gt;     * {example} sequenceKey("s1", "abc", 1) # "abc", "abc#1", "abc#2", ...&lt;BR /&gt;     * &lt;BR /&gt;     * {example} sequenceKey("s1", "abc", 3) # "abc", "abc#3", "abc#6", ...&lt;BR /&gt;     * &lt;BR /&gt;     */&lt;BR /&gt;    public static String setUniqueId(String seqName, String key, int step) {&lt;BR /&gt;        if (seq_Hash.containsKey(seqName)) {&lt;BR /&gt;        	if (key_Hash.get(seqName).containsKey(key)) {&lt;BR /&gt;        		return key + "#" + key_Hash.get(seqName).get(key);&lt;BR /&gt;        	} else {&lt;BR /&gt;        		Integer incValue = seq_Hash.get(seqName) + step;&lt;BR /&gt;	            seq_Hash.put(seqName, incValue);&lt;BR /&gt;	            key_Hash.get(seqName).put(key, incValue);&lt;BR /&gt;	            return key + "#" + incValue;&lt;BR /&gt;        	}&lt;BR /&gt;        } else {&lt;BR /&gt;            seq_Hash.put(seqName, startValue);&lt;BR /&gt;            key_Hash.put(seqName, new HashMap&amp;lt;Object, Integer&amp;gt;());&lt;BR /&gt;            return key;&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;}&lt;/PRE&gt;
&lt;BR /&gt;Here is a routine that should fit your needs.
&lt;BR /&gt;
&lt;BR /&gt;Instead of mapping 
&lt;U&gt;table1.name&lt;/U&gt; to 
&lt;U&gt;table2.name&lt;/U&gt;,
&lt;BR /&gt;map 
&lt;U&gt;SNumeric.getUniqueId("seq", table1.name, 1)&lt;/U&gt; to 
&lt;U&gt;table2.name&lt;/U&gt;.
&lt;BR /&gt;To get the current value of current name, you should have a table :
&lt;BR /&gt;
&lt;PRE&gt;sequence    label    id&lt;BR /&gt;seq         abc      4&lt;BR /&gt;seq         xyz      3&lt;BR /&gt;seq2        abc      1&lt;/PRE&gt;
&lt;BR /&gt;Then get 
&lt;I&gt;all&lt;/I&gt; those informations and create an "init" routine that initializes all the sequences.
&lt;BR /&gt;
&lt;BR /&gt;=== Second idea (think it's a better (easier) one than the first) ===
&lt;BR /&gt;You also may be able to "group" datas with a tAggregateRow and count rows.
&lt;BR /&gt;You should have something like :
&lt;BR /&gt;
&lt;PRE&gt;id name count&lt;BR /&gt;1  abc  3&lt;BR /&gt;2  xyz  1&lt;BR /&gt;3  efg  1&lt;/PRE&gt;
&lt;BR /&gt;Then you create a schema as below :
&lt;BR /&gt;
&lt;PRE&gt;                                                                                &lt;BR /&gt;                                                                                      |&lt;BR /&gt;                                                                                      v&lt;BR /&gt;----Iteration---&amp;gt;----Iteration---&amp;gt;----row---&amp;gt;----row---&amp;gt;&lt;/PRE&gt;
&lt;BR /&gt;The tLoop use the "count" column of the tAggregateRow. Then you should be able to treat rows individually and use a tMySQLInput for each.
&lt;BR /&gt;
&lt;BR /&gt;Sorry if my explanations aren't clear.
&lt;BR /&gt;I'll try to use printscreens if you don't understand.</description>
      <pubDate>Wed, 02 Jun 2010 13:44:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298758#M71183</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-06-02T13:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: Insert multiple unique records into MySQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298759#M71184</link>
      <description>Thanks I will give those methods a go, I'm not totally sure but it might become clearer as I try and set it up. I will report back how it goes.</description>
      <pubDate>Wed, 02 Jun 2010 14:50:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298759#M71184</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-06-02T14:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Insert multiple unique records into MySQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298760#M71185</link>
      <description>I've managed to get it to work a little bit, here's my screenshot.
&lt;BR /&gt;I wasn't sure how to setup the tLoop though.
&lt;BR /&gt;What it does at the moment is:
&lt;BR /&gt;
&lt;PRE&gt;Table 1 input:&lt;BR /&gt;id name&lt;BR /&gt;1  abc&lt;BR /&gt;2  xyz&lt;BR /&gt;3  abc&lt;BR /&gt;4  efg&lt;BR /&gt;5  abc&lt;BR /&gt;6  abc&lt;BR /&gt;Table 2 output:&lt;BR /&gt;id name&lt;BR /&gt;1  abc&lt;BR /&gt;2  xyz&lt;BR /&gt;3  abc#1&lt;BR /&gt;4  efg&lt;BR /&gt;5  unique key error tried to use the name: abc#1&lt;BR /&gt;6  unique key error tried to use the name: abc#1&lt;/PRE&gt;
&lt;BR /&gt;This seems to be because the group by is on the name, which doesn't allow for abc and abc#1 to be grouped together for the count so that the next value would be abc#2.
&lt;BR /&gt;The value after the # is the count from the group by.
&lt;BR /&gt;Thanks for your help so far but think I need some more guidance.</description>
      <pubDate>Wed, 02 Jun 2010 17:04:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298760#M71185</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-06-02T17:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: Insert multiple unique records into MySQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298761#M71186</link>
      <description>I've had another look at this and I am still struggling any help would be greatly appreciated, thanks.</description>
      <pubDate>Mon, 07 Jun 2010 17:43:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298761#M71186</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-06-07T17:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Insert multiple unique records into MySQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298762#M71187</link>
      <description>Hi I have to create a job where i take 
&lt;BR /&gt;a Fist_Name and Last_Name from a mssql db 
&lt;BR /&gt;and combine them so that it creates a username 
&lt;BR /&gt;Ex If the First_Name = John and the Last_Name = Perry 
&lt;BR /&gt;it should output it as JPerry. But my problem lies that when I created 
&lt;BR /&gt;that user name it should then check the LDAP AD if such a user name already exists 
&lt;BR /&gt;and if it does my job should then add a 1 after the username to = JPerry1 then it must search 
&lt;BR /&gt;the LDAP AD agian and if theres already a JPerry1 ist should then change to JPerry2 and so on 
&lt;BR /&gt;until theres a unique user name and then it should update the new username in LDAP. 
&lt;BR /&gt;I have already got my job to convert the to username and check if such a name already exists, 
&lt;BR /&gt;my output will then show the usernames that already exists in LDAP AD, now how can I use Talend to add a 1 
&lt;BR /&gt;after the username and loop the check again until a unique username is created. 
&lt;BR /&gt;If someone can help me with that I will appreciate it very much.</description>
      <pubDate>Sun, 05 Dec 2010 18:29:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Insert-multiple-unique-records-into-MySQL/m-p/2298762#M71187</guid>
      <dc:creator>Spretorius</dc:creator>
      <dc:date>2010-12-05T18:29:01Z</dc:date>
    </item>
  </channel>
</rss>

