<?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 Using a looped variable in SQL load where clause? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727132#M724118</link>
    <description>&lt;P&gt;Hi, is it possible when doing an SQL load to add a where clause that has values in an Oracle DB Column not equal to $(variable) ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variable will loop through a list of IDs so the resultant table now has rows of data for any new IDs only.&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 00:20:19 GMT</pubDate>
    <dc:creator>AyCe1082</dc:creator>
    <dc:date>2024-11-16T00:20:19Z</dc:date>
    <item>
      <title>Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727132#M724118</link>
      <description>&lt;P&gt;Hi, is it possible when doing an SQL load to add a where clause that has values in an Oracle DB Column not equal to $(variable) ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variable will loop through a list of IDs so the resultant table now has rows of data for any new IDs only.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 00:20:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727132#M724118</guid>
      <dc:creator>AyCe1082</dc:creator>
      <dc:date>2024-11-16T00:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727147#M724119</link>
      <description>&lt;P&gt;Yes, you can use the variable in SQL statement. Can you please elaborate further? You can do something like below&lt;/P&gt;&lt;P&gt;SQL&lt;/P&gt;&lt;P&gt;Select&amp;nbsp; ID&lt;/P&gt;&lt;P&gt;FROM schema.tablename&lt;/P&gt;&lt;P&gt;where ID not in '$(variable)'&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 21:22:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727147#M724119</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-07-12T21:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727155#M724120</link>
      <description>&lt;P&gt;Hi, I was wondering more about creating the loop itself (and having it compatible with the query). The loop would go through a list of numeric IDs one at a time while the SQL load is happening or if it is possible to have the entire list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The list could be something like&lt;/P&gt;&lt;P&gt;2213563&lt;/P&gt;&lt;P&gt;2213423&lt;/P&gt;&lt;P&gt;2231343&lt;/P&gt;&lt;P&gt;2245234&lt;/P&gt;&lt;P&gt;2235446&lt;/P&gt;&lt;P&gt;3345336&lt;/P&gt;&lt;P&gt;etc. and during the SQL load the variable would check all the IDs and only load in rows that don't match them. The list could be very large, possibly in the thousands so I am not sure if I should be using a loop or if the entire list can be used.&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 22:28:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727155#M724120</guid>
      <dc:creator>AyCe1082</dc:creator>
      <dc:date>2020-07-12T22:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727158#M724121</link>
      <description>&lt;P&gt;From where your list will come?&lt;/P&gt;</description>
      <pubDate>Sun, 12 Jul 2020 22:39:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727158#M724121</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-07-12T22:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727228#M724122</link>
      <description>&lt;P&gt;The list comes from a cmd execution that writes a list of PDF filenames from folders on the server (which contain the IDs in the name) to a text file and then breaks up the filenames to get the ID as its own column.&lt;/P&gt;&lt;P&gt;Then each SQL load will check the IDs from that list and only pull rows with new IDs from the DB, so the size of each query is kept to a minimum and NPrinting isn't generating the same PDFs on every reload.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 09:31:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727228#M724122</guid>
      <dc:creator>AyCe1082</dc:creator>
      <dc:date>2020-07-13T09:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727239#M724123</link>
      <description>&lt;P&gt;one option will be read the text file and store the values as concatenated list in variable and then use that variable in SQL where clause&lt;/P&gt;&lt;P&gt;List:&lt;/P&gt;&lt;P&gt;load concat(chr(39)&amp;amp;ID&amp;amp;chr(39),',') as List&lt;/P&gt;&lt;P&gt;FROM textfile;&lt;/P&gt;&lt;P&gt;let vList = peek('List',0,'List');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SQL&lt;/P&gt;&lt;P&gt;Select&amp;nbsp; ID&lt;/P&gt;&lt;P&gt;FROM schema.tablename&lt;/P&gt;&lt;P&gt;where ID not in '$(vList)';&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 09:57:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727239#M724123</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-07-13T09:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727253#M724124</link>
      <description>&lt;P&gt;I got a "string literal too long" error unfortunately.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 10:31:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727253#M724124</guid>
      <dc:creator>AyCe1082</dc:creator>
      <dc:date>2020-07-13T10:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727318#M724125</link>
      <description>&lt;P&gt;may be typo.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;List:&lt;/P&gt;&lt;P&gt;load concat(chr(39)&amp;amp;ID&amp;amp;chr(39),',') as List&lt;/P&gt;&lt;P&gt;FROM textfile;&lt;/P&gt;&lt;P&gt;let vList = peek('List',0,'List');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SQL&lt;/P&gt;&lt;P&gt;Select&amp;nbsp; ID&lt;/P&gt;&lt;P&gt;FROM schema.tablename&lt;/P&gt;&lt;P&gt;where ID not in &lt;STRONG&gt;(&lt;/STRONG&gt;$(vList)&lt;STRONG&gt;)&lt;/STRONG&gt;;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 12:43:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1727318#M724125</guid>
      <dc:creator>Kushal_Chawda</dc:creator>
      <dc:date>2020-07-13T12:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1728338#M724126</link>
      <description>&lt;P&gt;I use the following code and do get the ID numbers but the list is extremely long because there are I think a few thousand IDs.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="pdflist.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/37514i96E706E5715A89EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="pdflist.PNG" alt="pdflist.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;PDF:
LOAD 
     subfield([@40:n],'_',2) as report_matchdate,
     subfield([@40:n],'_',3) as report_matchname,
     subfield([@40:n],'_',4) as report_gameId,
     subfield([@40:n],'_',5) as report_version,
     replace(subfield([@40:n],'_',6),'.pdf','') as report_language,
     if(num([@21:38])&amp;lt;1000000,'repeat','complete') as report_state
FROM
[...\Match_Report\filelist_ORA1.txt]
(fix, codepage is 1252, header is 9 lines) where num([@21:39])&amp;gt;0 and num([@21:39])&amp;lt;10000000 ;

PDFList:
load concat(chr(39)&amp;amp;report_gameId&amp;amp;chr(39),',') as PDFlist
resident PDF;

let vList = peek('PDFlist',0,'PDFlist');

Then in the SQL load the line used is

AND   load.GAME_CODE not in '$(vList)'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 09:37:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1728338#M724126</guid>
      <dc:creator>AyCe1082</dc:creator>
      <dc:date>2020-07-16T09:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1728559#M724127</link>
      <description>&lt;P&gt;Of course, SQL strings are limited in length. Oracle has a limit of 409600 for SQL strings.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Your list has a lot of duplicate values. Use:&lt;/P&gt;&lt;P&gt;PDFList:&lt;BR /&gt;load concat(&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;distinct&lt;/FONT&gt;&lt;/STRONG&gt; chr(39) &amp;amp; report_gameId &amp;amp; chr(39),',') as PDFlist&lt;BR /&gt;resident PDF where len(report_gameId)&amp;gt;0;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;In the sql statement the list must be enclosed by parentheses:&lt;/P&gt;&lt;P&gt;where ... GAME_CODE not in &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;(&lt;/STRONG&gt;&lt;/FONT&gt;'$(vList)'&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 17:42:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1728559#M724127</guid>
      <dc:creator>cwolf</dc:creator>
      <dc:date>2020-07-16T17:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1728800#M724128</link>
      <description>&lt;P&gt;I don't think the string method will work, the string is just too long, even with distinct IDs.&lt;/P&gt;&lt;P&gt;The scroll bar in the image shows just how long the ID list is (and the list will just keep growing anyway).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="string.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/37635i0485B9F078FB9EE0/image-size/large?v=v2&amp;amp;px=999" role="button" title="string.PNG" alt="string.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 11:23:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1728800#M724128</guid>
      <dc:creator>AyCe1082</dc:creator>
      <dc:date>2020-07-17T11:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1729071#M724129</link>
      <description>&lt;P&gt;I have tried a different method and am close to the end but I have to get this last step right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have now two qvds,&lt;/P&gt;&lt;P&gt;The first qvd named ReportsTracker(which is created from the text file) has the unique IDs, a key I made, and a status column that is 0 or 1. It's a 1 if a filename exists in the server (so there is a PDF).&lt;/P&gt;&lt;P&gt;The second qvd named ReportsMain has all the data I pulled from the DB including IDs plus the key and status column manually added in after. The status column is always 0 here.&lt;/P&gt;&lt;P&gt;The goal is to change the values in the status column of ReportsMain from 0 to 1, if it happens to be a 1 in the ReportsTracker qvd. I know I am currently doing it wrong in the code below, as the final table is just what was in the ReportsTracker qvd. I'm wondering how to finish this and have it working? If applymap is the way to go or some type of join?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;Main:
LOAD *
FROM
[D:\QlikView\DEV\DBQVD\Soccer\ReportsTracker.qvd]
(qvd);

Concatenate(Main)
LOAD *
FROM
[D:\QlikView\DEV\DBQVD\Soccer\ReportsMain.qvd]
(qvd)

where not exists(Reportkey);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 20:11:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1729071#M724129</guid>
      <dc:creator>AyCe1082</dc:creator>
      <dc:date>2020-07-19T20:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using a looped variable in SQL load where clause?</title>
      <link>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1729160#M724130</link>
      <description>&lt;P&gt;Got it working with mapping load. All is good now. I don't know how to lock or delete a topic.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jul 2020 10:30:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-a-looped-variable-in-SQL-load-where-clause/m-p/1729160#M724130</guid>
      <dc:creator>AyCe1082</dc:creator>
      <dc:date>2020-07-20T10:30:42Z</dc:date>
    </item>
  </channel>
</rss>

