<?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 WHERE EXISTS using concatenated primary key for incremental load in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/WHERE-EXISTS-using-concatenated-primary-key-for-incremental-load/m-p/2524262#M106865</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I need some help with this. I'm trying to create an &lt;STRONG&gt;incremental load&lt;/STRONG&gt; from a database table. The issue is that the &lt;STRONG&gt;primary key&lt;/STRONG&gt; of this table is composed of &lt;STRONG&gt;two concatenated fields&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;I want to use a WHERE EXISTS clause to filter only the &lt;STRONG&gt;new or recently updated records&lt;/STRONG&gt;, based on this concatenated key. However, I'm not sure how to properly implement it so I don’t miss any relevant data.&lt;/P&gt;&lt;P&gt;Have any of you faced a similar situation? Could you help me understand how to apply WHERE EXISTS when the key is made up of two fields?&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;Let vCampoIncremental = 'DATEALT';&lt;BR /&gt;Let vPK = 'NNUMEMCON';&lt;BR /&gt;Let vDataCorteIncremental = Date(Today());&lt;/P&gt;&lt;P&gt;//carregando dados do banco&lt;BR /&gt;[$(vTabela)]:&lt;BR /&gt;SQL SELECT * FROM $(vEsquema).$(vTabela)&lt;BR /&gt;WHERE $(vTabela).$(vCampoIncremental) &amp;gt;= TO_DATE('$(vDataCorteIncremental)','DD/MM/YYYY');&lt;/P&gt;&lt;P&gt;Concatenate&lt;BR /&gt;LOAD * FROM&lt;BR /&gt;[lib://Tabelas Puras:DataFiles/$(vEsquema)/$(vTabela).QVD](qvd)&lt;BR /&gt;WHERE NOT EXISTS($(vPK));&lt;/P&gt;&lt;P&gt;Inner Join SELECT "$(vPK)" FROM "$(vEsquema)"."$(vTabela)";&lt;/P&gt;&lt;P&gt;Store [$(vTabela)] into [lib://Tabelas Puras:DataFiles/$(vConexao)/$(vTabela).QVD];&lt;BR /&gt;DROP Table [$(vTabela)];&lt;/P&gt;</description>
    <pubDate>Tue, 15 Jul 2025 11:32:52 GMT</pubDate>
    <dc:creator>V_Ortis</dc:creator>
    <dc:date>2025-07-15T11:32:52Z</dc:date>
    <item>
      <title>WHERE EXISTS using concatenated primary key for incremental load</title>
      <link>https://community.qlik.com/t5/App-Development/WHERE-EXISTS-using-concatenated-primary-key-for-incremental-load/m-p/2524262#M106865</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I need some help with this. I'm trying to create an &lt;STRONG&gt;incremental load&lt;/STRONG&gt; from a database table. The issue is that the &lt;STRONG&gt;primary key&lt;/STRONG&gt; of this table is composed of &lt;STRONG&gt;two concatenated fields&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;I want to use a WHERE EXISTS clause to filter only the &lt;STRONG&gt;new or recently updated records&lt;/STRONG&gt;, based on this concatenated key. However, I'm not sure how to properly implement it so I don’t miss any relevant data.&lt;/P&gt;&lt;P&gt;Have any of you faced a similar situation? Could you help me understand how to apply WHERE EXISTS when the key is made up of two fields?&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;Let vCampoIncremental = 'DATEALT';&lt;BR /&gt;Let vPK = 'NNUMEMCON';&lt;BR /&gt;Let vDataCorteIncremental = Date(Today());&lt;/P&gt;&lt;P&gt;//carregando dados do banco&lt;BR /&gt;[$(vTabela)]:&lt;BR /&gt;SQL SELECT * FROM $(vEsquema).$(vTabela)&lt;BR /&gt;WHERE $(vTabela).$(vCampoIncremental) &amp;gt;= TO_DATE('$(vDataCorteIncremental)','DD/MM/YYYY');&lt;/P&gt;&lt;P&gt;Concatenate&lt;BR /&gt;LOAD * FROM&lt;BR /&gt;[lib://Tabelas Puras:DataFiles/$(vEsquema)/$(vTabela).QVD](qvd)&lt;BR /&gt;WHERE NOT EXISTS($(vPK));&lt;/P&gt;&lt;P&gt;Inner Join SELECT "$(vPK)" FROM "$(vEsquema)"."$(vTabela)";&lt;/P&gt;&lt;P&gt;Store [$(vTabela)] into [lib://Tabelas Puras:DataFiles/$(vConexao)/$(vTabela).QVD];&lt;BR /&gt;DROP Table [$(vTabela)];&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jul 2025 11:32:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/WHERE-EXISTS-using-concatenated-primary-key-for-incremental-load/m-p/2524262#M106865</guid>
      <dc:creator>V_Ortis</dc:creator>
      <dc:date>2025-07-15T11:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE EXISTS using concatenated primary key for incremental load</title>
      <link>https://community.qlik.com/t5/App-Development/WHERE-EXISTS-using-concatenated-primary-key-for-incremental-load/m-p/2524282#M106869</link>
      <description>&lt;P&gt;Not sure but did you try making a composite key like Field1 &amp;amp; '|'&amp;amp; Field2 and try WHERE NOT EXISTS(Field1 &amp;amp; '|'&amp;amp; Field2)? I might be missing something but wanted to understand what options you have tried..&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jul 2025 13:01:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/WHERE-EXISTS-using-concatenated-primary-key-for-incremental-load/m-p/2524282#M106869</guid>
      <dc:creator>Digvijay_Singh</dc:creator>
      <dc:date>2025-07-15T13:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE EXISTS using concatenated primary key for incremental load</title>
      <link>https://community.qlik.com/t5/App-Development/WHERE-EXISTS-using-concatenated-primary-key-for-incremental-load/m-p/2524292#M106871</link>
      <description>&lt;P&gt;With Exists(), it is better to use a composite key on both ends of the comparison as suggested by&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/48860"&gt;@Digvijay_Singh&lt;/a&gt;&amp;nbsp;since this will allow optimized QVD reading. If you're using NOT EXISTS, this is off the table anyway so you can also pull the composite key from the first source and then concatenate on the fly for the second source. This will look something like:&lt;/P&gt;&lt;P&gt;Load Field1, Field2, Field3, Field1 &amp;amp; '|' Field2 as myKey&lt;/P&gt;&lt;P&gt;From Source1;&lt;/P&gt;&lt;P&gt;Load Field1, Field2, Field3&lt;/P&gt;&lt;P&gt;From Source2&lt;/P&gt;&lt;P&gt;Where Not Exists (myKey,Field1 &amp;amp; '|' &amp;amp; 'Field2')&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jul 2025 13:50:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/WHERE-EXISTS-using-concatenated-primary-key-for-incremental-load/m-p/2524292#M106871</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2025-07-15T13:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE EXISTS using concatenated primary key for incremental load</title>
      <link>https://community.qlik.com/t5/App-Development/WHERE-EXISTS-using-concatenated-primary-key-for-incremental-load/m-p/2524485#M106895</link>
      <description>&lt;P&gt;Yes, i tried using only field1&amp;amp;field2, but some datas got duplicated this way, so before saving the QVD i had to generate a unique key by concatenating both fields.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jul 2025 19:30:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/WHERE-EXISTS-using-concatenated-primary-key-for-incremental-load/m-p/2524485#M106895</guid>
      <dc:creator>V_Ortis</dc:creator>
      <dc:date>2025-07-16T19:30:00Z</dc:date>
    </item>
  </channel>
</rss>

