<?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: Complex SQL query in tDBInput in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337097#M105470</link>
    <description>&lt;P&gt;Yes, there are some aliases missing. Actually you are right, why the hack there are output records?&lt;/P&gt;&lt;P&gt;Actually I would expect an SQL error because of the ambiguous columns! &lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2022 07:37:41 GMT</pubDate>
    <dc:creator>jlolling</dc:creator>
    <dc:date>2022-12-07T07:37:41Z</dc:date>
    <item>
      <title>Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337091#M105464</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have input data from a tMap. I need to use some columns (in bold in the query below) to run a SQL query from a tDBInput "Lookup". I have several thousand rows of input so I don't want to use the "Reload at each row" option as it takes too long. I just need to find a method to correctly inject my tMap data into the query and get the result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;The query : &lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select distinct a.ID_FAM, &lt;/P&gt;&lt;P&gt;into :idFam%, :idAy%, :idOrg1%, :IdProd$&lt;/P&gt;&lt;P&gt;from AY a, FPROD fp, PROD P, ORG O, DCSE D&lt;/P&gt;&lt;P&gt;where&amp;nbsp;&lt;B&gt;&lt;I&gt;a.AY_SS&lt;/I&gt;&lt;/B&gt;&amp;nbsp;= '&lt;B&gt;TALEND_COL1&lt;/B&gt;'&lt;/P&gt;&lt;P&gt;and a.ID_FAM = fp.ID_FAM&lt;/P&gt;&lt;P&gt;and fp.ID_ORG = a.ID_ORG&lt;/P&gt;&lt;P&gt;and fp.ID_ORG = P.ID_ORG&lt;/P&gt;&lt;P&gt;and fp.ID_PROD = P.ID_PROD&lt;/P&gt;&lt;P&gt;and fp.ID_ORG = O.ID_ORG&lt;/P&gt;&lt;P&gt;and D.DCSE_NOM = 'NOEMIE'&lt;/P&gt;&lt;P&gt;and ((('NOEMIE' &amp;lt;&amp;gt; 'NOEMIE' and D.DCSE_PP = 0) and fp.ID_PROD = 'SANTE') or (('NOEMIE' = 'NOEMIE' or D.DCSE_PP = 1) and (fp.ID_PROD = O.ORG_PROD or P.PROD_PRESTATION_SANTE = 1)))&lt;/P&gt;&lt;P&gt;and fp.ID_FAM = a.ID_FAM&lt;/P&gt;&lt;P&gt;and ((&lt;B&gt;&lt;I&gt;a.AY_DATNAIS&lt;/I&gt;&lt;/B&gt;&amp;nbsp;=&amp;nbsp;decode('&lt;B&gt;TALEND_COL2&lt;/B&gt;', 1, to_date('&lt;B&gt;TALEND_COL2&lt;/B&gt;', 'dd/mm/yyyy'),&amp;nbsp;&lt;B&gt;&lt;I&gt;a.AY_DATNAIS&lt;/I&gt;&lt;/B&gt;)) or (&lt;B&gt;&lt;I&gt;a.AY_DATNAIS2&lt;/I&gt;&lt;/B&gt;&amp;nbsp;= '&lt;B&gt;TALEND_COL2&lt;/B&gt;'))&lt;/P&gt;&lt;P&gt;and&lt;I&gt;&amp;nbsp;&lt;/I&gt;&lt;B&gt;&lt;I&gt;a.AY_RNG&lt;/I&gt;&lt;/B&gt;&amp;nbsp;=&amp;nbsp;&lt;B&gt;TALEND_COL3&lt;/B&gt;&lt;/P&gt;&lt;P&gt;and exists (select 'a'&lt;/P&gt;&lt;P&gt; from ADC ad&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;where ad.ID_AY = a.ID_AY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;and ad.ID_PROD = fp.ID_PROD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;and nvl(ad.id_fprod, fp.id_fprod) = fp.id_fprod&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;and to_date(&lt;B&gt;TALEND_COL4&lt;/B&gt;', 'DD/MM/RR') between ad.ADC_DATDEB and nvl( ad.ADC_DATRAD, sysdate+1))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;and to_date('&lt;B&gt;TALEND_COL4&lt;/B&gt;', 'DD/MM/RR') between&amp;nbsp;fp.FP_DATADH and nvl( fp.FP_DATRAD, sysdate+1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;A small illustration of what I have started to do :&amp;nbsp;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEerRAAS.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/135066iD896B60C6B5F7BA2/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEerRAAS.png" alt="0695b00000aEerRAAS.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEenAAAS.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/137689iEA47EB5769C59EAF/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEenAAAS.png" alt="0695b00000aEenAAAS.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEenjAAC.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/148398i2F018918C602A265/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEenjAAC.png" alt="0695b00000aEenjAAC.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I moved the conditions requiring input values after the select except for TALEND _COL4 where I wrote the data myself because obviously that's why I need your help.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 22:17:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337091#M105464</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2024-11-15T22:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337092#M105465</link>
      <description>&lt;P&gt;Whats wrong with the Reload Each Row option? You can use globalMap values to take care the lookup-select provides fast the expected data by instrumenting the where clause.&lt;/P&gt;&lt;P&gt;And BTW, thousands of rows are not a problem for the tMap if you can limit the columns to the really needed. I have used lookups with 20 millions rows and use Load at once! &lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 23:33:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337092#M105465</guid>
      <dc:creator>jlolling</dc:creator>
      <dc:date>2022-12-06T23:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337093#M105466</link>
      <description>&lt;P&gt;Hello @Jan Lolling​&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your feedback. I would like to benefit from it to have the same results as you in terms of speed. It's true that I'm missing out on an interesting option, but when I tested it my processing time is getting much longer. Which scared me. I don't think I'm using it properly so I'm willing to show you how I do it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEf9pAAC.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/153937i7BF9073232D1D244/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEf9pAAC.png" alt="0695b00000aEf9pAAC.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEf91AAC.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/136156iAC402815D93D6A5B/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEf91AAC.png" alt="0695b00000aEf91AAC.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For information, the input columns "output_data2" represent about 4000 rows for the file I am processing.&amp;nbsp;Here is an overview of my input columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEfCjAAK.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/131921i3D9C537E1DA73EE8/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEfCjAAK.png" alt="0695b00000aEfCjAAK.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;﻿It takes 1 minute in total when I don't add globalMap as in the screenshots in my first comment.&amp;nbsp;To increase the performance of the query a bit, I added the distinct after the select and enabled the advanced settings slider.&amp;nbsp; After adding globalMap, it has been 10 minutes since I ran the job and it still doesn't finish...&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 23:45:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337093#M105466</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2022-12-06T23:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337094#M105467</link>
      <description>&lt;P&gt;One issue is also the tDBInput component for the lookup does not use an external connection. If not the component establish for EACH row a new connection and this slows down a lot.&lt;/P&gt;&lt;P&gt;Take care you put a tDBConnection before the entire subjob with the mentioned tMap.&lt;/P&gt;&lt;P&gt;The next thing is you have to take care the where condition is supported by an index. Your query actually does not allow using an index because the where condition use the given values inside of functions and this prevents using index. I would recommend using a helper table to simplify the select.&lt;/P&gt;&lt;P&gt;E.G. you could collect all repo_datro which will occur in your source and build a temporary table containing all the related records and now you have a very fast table for the lookup. &lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 23:54:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337094#M105467</guid>
      <dc:creator>jlolling</dc:creator>
      <dc:date>2022-12-06T23:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337095#M105468</link>
      <description>&lt;P&gt;Thank you for this information, but I admit that I have difficulty in understanding. Or at least to imagine it. If you have a demonstration or an illustration, that would be great. In any case, I will try to think about it.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 00:01:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337095#M105468</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2022-12-07T00:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337096#M105469</link>
      <description>&lt;P&gt;I'm curious, where is this data coming from? Is it all from the same database? If so, why not carry out the join in a single query? A database is built for effective querying of data. If it is all in the same DB, there is no point bringing it out to carry out a join. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this data is not all in the same DB, then if you do not want to fire a query for every one of your main rows, you can just load all of the data from your sources and join in a tMap. Now, there may be some memory issues doing it this way, but it is worth giving it a try. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am also confused by your SQL. You have a couple of conditions that do make any sense. For example,.....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;('NOEMIE' &amp;lt;&amp;gt; 'NOEMIE' and D.DCSE_PP = 0) &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.... will always be false. 'NOEMIE' is always equal to 'NOEMIE'. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Likewise, this will be true all the time....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;('NOEMIE' = 'NOEMIE' or D.DCSE_PP = 1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;....since 'NOEMIE' is always equal to 'NOEMIE' and since you are using an "OR" it doesn't matter about the D.DCSE_PP = 1. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These extra conditions that achieve nothing will not help your performance.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 02:33:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337096#M105469</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-07T02:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337097#M105470</link>
      <description>&lt;P&gt;Yes, there are some aliases missing. Actually you are right, why the hack there are output records?&lt;/P&gt;&lt;P&gt;Actually I would expect an SQL error because of the ambiguous columns! &lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 07:37:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337097#M105470</guid>
      <dc:creator>jlolling</dc:creator>
      <dc:date>2022-12-07T07:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337098#M105471</link>
      <description>&lt;P&gt;Reload Each Row option only make sense if you get this way exactly these records related to the incoming records of the main flow. Or you want to have multiple output records based of one input record.&lt;/P&gt;&lt;P&gt;You have to explain your use case a little bit deeper.&lt;/P&gt;&lt;P&gt;I guess the explanation with the tDBConnection is quite clear or not?&lt;/P&gt;&lt;P&gt;I mean add a tDBConnection to the job and use it before you trigger the subjob containing your mentioned tDBInput . Than reference this tDBConnection from your lookup tDBInput. This will prevent the job from establishing every record a new connection.&lt;/P&gt;&lt;P&gt;The other thing with the temp table can only be more concrete if we understand your use case. &lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 07:45:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337098#M105471</guid>
      <dc:creator>jlolling</dc:creator>
      <dc:date>2022-12-07T07:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337099#M105472</link>
      <description>&lt;P&gt;Hello @Richard Hall​ and @Jan Lolling​,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data is in a file that I need to process and integrate into a single database. So in Talend, the process is tJavaFlex --&amp;gt; tMap --&amp;gt; tDBOutput. The columns are extracted from the file with substring() in tJavaFlex. To come back to the complex query, the objective is that using the data (columns), execute it. If this one returns a result (to check that a member exists in the base using its identifier, date of birth... to put in the request) then I define the value of another column.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So then what I'll do is :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEgvGAAS.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/136558i8D8317A964B39AFD/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEgvGAAS.png" alt="0695b00000aEgvGAAS.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEguwAAC.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/153462i9BC5504101920ABC/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEguwAAC.png" alt="0695b00000aEguwAAC.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for example with this data in input of the tJavaFlex, the query should return no rows (tested in bdd) and return 1 in the other column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEgwYAAS.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/145009i0688D7AFAA53914E/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEgwYAAS.png" alt="0695b00000aEgwYAAS.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEgwTAAS.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/149383i9751FD35AA483A4F/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEgwTAAS.png" alt="0695b00000aEgwTAAS.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As described above, to inject the first columns into Talend, I removed the rows from the query to place the relevant fields in front of the SELECT (and defined in the schema). I then assigned the data from my tJavaFlex to each of the schema columns (in tMap).&lt;/P&gt;&lt;P&gt;But as you have understood, I don't know how to proceed to do the same with :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and to_date('&lt;B&gt;18/05/1990&lt;/B&gt;', 'DD/MM/RR') between ad.ADC_DATDEB and nvl(ad.ADC_DATRAD, sysdate+1))&lt;/P&gt;&lt;P&gt;and to_date('&lt;B&gt;18/05/1990&lt;/B&gt;', 'DD/MM/RR') between fp.FP_DATADH and nvl( fp.FP_DATRAD, sysdate+1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what is currently blocking me. This is the first time I've encountered a query like this. Usually when it's a condition like "col1 = value" then I do as with the first columns of this query. But this is different because it is "col1 between and". I can't take col1 and put it in front of SELECT because otherwise what do I do with "between and"?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEgxlAAC.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/148981iB937114E09560E8C/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEgxlAAC.png" alt="0695b00000aEgxlAAC.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEgxqAAC.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/136564i0D16F292AF712167/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEgxqAAC.png" alt="0695b00000aEgxqAAC.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thank you for the remark about the confusing query. I should have left the original one, because 'NOEMIE' is also a data of a column in my file. So I put 'NOEMIE' because I am 100% sure that all my rows have this value and it takes away a difficulty to insert a column from my tMap in my query. But this is not the case for &lt;B&gt;TALEND_COL4&lt;/B&gt; where in this case the dates are variable and not fixed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 09:41:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337099#M105472</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2022-12-07T09:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337100#M105473</link>
      <description>&lt;P&gt;OK, lets go through this in stages. Can you test this query (it may require a few tweaks) and replace your query with this one? Your query had some unnecessary sections and wasn't efficient. You even had a cartesian join in there. The DCSE table was not joined to anything and no data was being returned from it. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SELECT distinct a.ID_FAM, a.AY_SS, a.AY_DATNAIS, a.AY_DATNAIS2, a.AY_RNG&lt;/P&gt;&lt;P&gt;FROM AY a INNER JOIN FPROD fp ON a.ID_FAM = fp.ID_FAM AND&lt;/P&gt;&lt;P&gt;a.ID_ORG = fp.ID_ORG&lt;/P&gt;&lt;P&gt;INNER JOIN PROD P ON fp.ID_ORG = P.ID_ORG AND&lt;/P&gt;&lt;P&gt;fp.ID_PROD = P.ID_PROD&lt;/P&gt;&lt;P&gt;INNER JOIN ORG O ON fp.ID_ORG = O.ID_ORG&lt;/P&gt;&lt;P&gt;INNER JOIN ADC ad ON a.ID_AY = ad.ID_AY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WHERE a.AY_SS = 'TALEND_COL1' AND&lt;/P&gt;&lt;P&gt;((fp.ID_PROD = 'SANTE') OR (fp.ID_PROD = O.ORG_PROD OR P.PROD_PRESTATION_SANTE = 1)) AND&lt;/P&gt;&lt;P&gt;((a.AY_DATNAIS = decode('TALEND_COL2', 1, to_date('TALEND_COL2', 'dd/mm/yyyy'), a.AY_DATNAIS)) OR (a.AY_DATNAIS2 = 'TALEND_COL2')) AND&lt;/P&gt;&lt;P&gt;a.AY_RNG = TALEND_COL3 AND&lt;/P&gt;&lt;P&gt;ad.ID_PROD = fp.ID_PROD AND&lt;/P&gt;&lt;P&gt;nvl(ad.id_fprod, fp.id_fprod) = fp.id_fprod AND&lt;/P&gt;&lt;P&gt;to_date(TALEND_COL4', 'DD/MM/RR') between ad.ADC_DATDEB and nvl( ad.ADC_DATRAD, sysdate+1)) AND&lt;/P&gt;&lt;P&gt;to_date('TALEND_COL4', 'DD/MM/RR') between fp.FP_DATADH and nvl( fp.FP_DATRAD, sysdate+1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should be all you need. Obviously, I haven't been able to test it. So you may need to tweak it, but not by much. This is based on the SQL you showed in your first post. There are some Talend variables in here (I've kept everything named the same), so you will have to modify this with values to test it. This query should be significantly quicker.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:12:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337100#M105473</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-07T11:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337101#M105474</link>
      <description>&lt;P&gt;Thank you very much @Richard Hall​&amp;nbsp;, the SQL query works very well and is more optimised. As expected with these values (4 columns), it returns nothing. But with other values, it can return a row.&lt;/P&gt;&lt;P&gt;So I come back to the main problem, what method can I use to inject the values from the tMap into the SQL query of the tDBInput.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEhOhAAK.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/156686iF1138F5213DB2670/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEhOhAAK.png" alt="0695b00000aEhOhAAK.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEhQTAA0.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/155264iB417BA3597C1737B/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEhQTAA0.png" alt="0695b00000aEhQTAA0.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEhOnAAK.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/142051i011E6B2359EA955D/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEhOnAAK.png" alt="0695b00000aEhOnAAK.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:48:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337101#M105474</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2022-12-07T11:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337102#M105475</link>
      <description>&lt;P&gt;If you want to inject values, you HAVE to use the "Reload Each Row" option. Otherwise, how will the values be selected?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, there is another way. How many rows are returned if you leave out the WHERE clause options which use these injected values? I suspect that you can carry out your lookup by simply loading ALL of the data returned and use the tMap to join to this data in order to filter it down.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 12:26:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337102#M105475</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-07T12:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337103#M105476</link>
      <description>&lt;P&gt;Ok @Richard Hall​. Is the setting in tMap as below correct?&lt;/P&gt;&lt;P&gt;I used a filter because I need to run the query for only a few rows (about 4000) out of 20000.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEi1tAAC.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/132941iFDFE713CB5D35CDE/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEi1tAAC.png" alt="0695b00000aEi1tAAC.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEi2hAAC.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/144129i66982E6A94A11827/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEi2hAAC.png" alt="0695b00000aEi2hAAC.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Query with WHERE clauses return at most one row. It is about finding a member thanks to the data I inject from the tMap.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 13:05:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337103#M105476</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2022-12-07T13:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337104#M105477</link>
      <description>&lt;P&gt;OK, I think there is some confusion here. How many rows of data are in your main source (the file)? I assume you are saying that there are 20,000 in your lookup and that you are reducing this to 4000 with your filter in the tMap. Out of interest, why aren't you filtering the number of rows from 20,000 to 4000 in your SQL?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are only using 4000 rows in your lookup, you may as well just load all of the data once and use the tMap joins to get to the data you need. When you join your Main to your Lookup, it will exclude any data that does not meet that join. So, it will be quicker than firing the query on every row. &lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 13:19:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337104#M105477</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-07T13:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337105#M105478</link>
      <description>&lt;P&gt;@Richard Hall​&amp;nbsp;My tMap input data is about 20,000 lines. I just need to run the query on 4000 rows, the one with type 223 or 255.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEiKlAAK.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/149208iAD9E7D02A821AAD1/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEiKlAAK.png" alt="0695b00000aEiKlAAK.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My result after injecting the values (of more than 4000 rows) as input to the SQL query should be like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEiR3AAK.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/133374i96E698FFE4FF82F2/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEiR3AAK.png" alt="0695b00000aEiR3AAK.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These are not of course the real data, but the query must return for each line, the member's identifier if it exists otherwise null. I don't usually have problems with tDBInput except for this query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I usually do it like this, a simple example. The original query :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"SELECT id_org&lt;/P&gt;&lt;P&gt;from org&lt;/P&gt;&lt;P&gt;where org_noc = TALEND_COL1"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In tDBInput : &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEiTnAAK.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/156656iB01734EEE49DF0C5/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEiTnAAK.png" alt="0695b00000aEiTnAAK.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In tMap&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEiURAA0.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/135353i8FEAB0E1728B2733/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEiURAA0.png" alt="0695b00000aEiURAA0.png" /&gt;&lt;/span&gt;And I have my exit for the 4000 lines&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000aEiYOAA0.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/139162i676A8D50DBB1CC1F/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000aEiYOAA0.png" alt="0695b00000aEiYOAA0.png" /&gt;&lt;/span&gt;In the current case, this is really difficult because the CLAUSE concerned by the input value is not of the type :&amp;nbsp;﻿&lt;/P&gt;&lt;P&gt;WHERE col1 = TALEND_COL1. But within the SQL query itself...&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 13:42:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337105#M105478</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2022-12-07T13:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337106#M105479</link>
      <description>&lt;P&gt;I tested by injecting the data with globalMap (as in my screenshot in the last comment). As expected it works, but the execution time of the job went from 1-2mn to 27mn. This is not surprising as if it loads the SQL query on each line, with 4000 lines it will take a long time.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 14:51:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337106#M105479</guid>
      <dc:creator>stephbzr</dc:creator>
      <dc:date>2022-12-07T14:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: Complex SQL query in tDBInput</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337107#M105480</link>
      <description>&lt;P&gt;You don't need to inject the values and Reload Each Row. Just use the query without the injected values and join inside the tMap. Let the tMap joins deal with finding the rows that you need. 20,000 rows is not too large for a lookup if it is just a single query. When you do not select Reload Each Row, it loads all of the rows and stores them in memory in the job. Then, when every Main row comes through, they are each matched against the lookup data in memory.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 15:48:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Complex-SQL-query-in-tDBInput/m-p/2337107#M105480</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-07T15:48:04Z</dc:date>
    </item>
  </channel>
</rss>

