<?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 Urgent: How to use result set from one SQL , use it as a variable and use it in different query in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323008#M119003</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want value of a field from one table and use this value for creating another table. I've used the following script but the variable is not getting interpolated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966;"&gt;ODBC CONNECT TO database (XUserId is NDJeQRdNHbXEWRRMfaYKHRVMfC, XPassword is LQAJdBVGVBOGTZcNHTAB);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #339966;"&gt;SQL create table abc.qlikview_max_dt as (select max(login_dt) as max_dt from abc.sample1) with data ;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #339966;"&gt;ValueFromSQL1: select max_dt from d_cog_t.qlikview_max_dt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #339966;"&gt;Table1: Load max_dt as aa resident ValueFromSQL1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #339966;"&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #339966;"&gt;set max_dt_val=fieldvalue('aa',0,Table1);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #339966;"&gt;SQL drop table abc.qlikview_max_dt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966;"&gt;&lt;SPAN style="color: #339966;"&gt;SQL create table abc.newTable as (select log_user_id,login_dt,touch_ti from &lt;/SPAN&gt;abc.sample1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #339966;"&gt;where login_dt = $(max_dt_val)) with data; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I'm able to establish connection to database and create abc.qlikview_max_dt table.I'm also able to drop the mentioned table.&lt;BR /&gt;However, when I assign fieldvalue('aa',0,Table1) to max_dt_val variable, its value is not getting expanded in SQL. I tried using peek function also. This is the error I get:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;SQL Error:[Teradata][ODBC Teradata Driver][Teradata Database] Syntax error: expected something between '(' and the string 'a' keyword. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;SQL Scriptline:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;SQL State:37000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;select * from abc.sample1 where login_dt=fieldvalue('aa',0,Table1) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me,as it is very urgent.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Nov 2011 05:25:00 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-11-16T05:25:00Z</dc:date>
    <item>
      <title>Urgent: How to use result set from one SQL , use it as a variable and use it in different query</title>
      <link>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323008#M119003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want value of a field from one table and use this value for creating another table. I've used the following script but the variable is not getting interpolated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966;"&gt;ODBC CONNECT TO database (XUserId is NDJeQRdNHbXEWRRMfaYKHRVMfC, XPassword is LQAJdBVGVBOGTZcNHTAB);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #339966;"&gt;SQL create table abc.qlikview_max_dt as (select max(login_dt) as max_dt from abc.sample1) with data ;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #339966;"&gt;ValueFromSQL1: select max_dt from d_cog_t.qlikview_max_dt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #339966;"&gt;Table1: Load max_dt as aa resident ValueFromSQL1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #339966;"&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #339966;"&gt;set max_dt_val=fieldvalue('aa',0,Table1);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #339966;"&gt;SQL drop table abc.qlikview_max_dt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966;"&gt;&lt;SPAN style="color: #339966;"&gt;SQL create table abc.newTable as (select log_user_id,login_dt,touch_ti from &lt;/SPAN&gt;abc.sample1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #339966;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #339966;"&gt;where login_dt = $(max_dt_val)) with data; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I'm able to establish connection to database and create abc.qlikview_max_dt table.I'm also able to drop the mentioned table.&lt;BR /&gt;However, when I assign fieldvalue('aa',0,Table1) to max_dt_val variable, its value is not getting expanded in SQL. I tried using peek function also. This is the error I get:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;SQL Error:[Teradata][ODBC Teradata Driver][Teradata Database] Syntax error: expected something between '(' and the string 'a' keyword. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;SQL Scriptline:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;SQL State:37000&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;select * from abc.sample1 where login_dt=fieldvalue('aa',0,Table1) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me,as it is very urgent.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 05:25:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323008#M119003</guid>
      <dc:creator />
      <dc:date>2011-11-16T05:25:00Z</dc:date>
    </item>
    <item>
      <title>Urgent: How to use result set from one SQL , use it as a variable and use it in different query</title>
      <link>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323009#M119004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Instead of SET use LET. Also check it the the SQL date data type will match with qv variable. If not format the variable in SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kiran.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 05:45:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323009#M119004</guid>
      <dc:creator />
      <dc:date>2011-11-16T05:45:41Z</dc:date>
    </item>
    <item>
      <title>Urgent: How to use result set from one SQL , use it as a variable and use it in different query</title>
      <link>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323010#M119005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;let var= peek(' aa',0,tablename);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope it will work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 07:26:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323010#M119005</guid>
      <dc:creator />
      <dc:date>2011-11-16T07:26:22Z</dc:date>
    </item>
    <item>
      <title>Urgent: How to use result set from one SQL , use it as a variable and use it in different query</title>
      <link>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323011#M119006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks Kiran,&lt;/P&gt;&lt;P&gt;I've changed set to let and though there are no syntax errors seen, the table abc.newTable gets created without any records.&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt; &lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt; &lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;SQL select max(login_dt) as max_dt_val from abc.sample1;&lt;/P&gt;&lt;P&gt;SQL drop table abc.newTable;&lt;/P&gt;&lt;P&gt;SQL create table abc.newTable as (select log_user_id,login_dt,touch_ti from abc.sample1&lt;/P&gt;&lt;P&gt;where login_dt = $(max_dt_val)) with data;&lt;/P&gt;&lt;P&gt;NewTable: select * from d_cog_t.newTable;&lt;/P&gt;&lt;P&gt;Load * resident NewTable; &lt;/P&gt;&lt;P&gt;The table newTable does not contain any records. However if I use a subquery instead of max_dt_val ie&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;create table abc.newTable as (select log_user_id,login_dt,touch_ti from abc.sample1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where login_dt =(select max(login_dt) as max_dt from abc.sample1)) with data;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;, the table newTable contains records which is the exact output.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 07:33:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323011#M119006</guid>
      <dc:creator />
      <dc:date>2011-11-16T07:33:21Z</dc:date>
    </item>
    <item>
      <title>Urgent: How to use result set from one SQL , use it as a variable and use it in different query</title>
      <link>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323012#M119007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can enable the show Generate Log files in Document Properties -&amp;gt; General. When you reload it will track the script executed and you can have a look at the run time script. There must be some issue with the data formatting, which can be found thru log file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub query is not a good practise if the data size is heavy. Besides variable can be reusable all throught. So lets try resolving with variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kiran.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 07:46:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323012#M119007</guid>
      <dc:creator />
      <dc:date>2011-11-16T07:46:38Z</dc:date>
    </item>
    <item>
      <title>Urgent: How to use result set from one SQL , use it as a variable and use it in different query</title>
      <link>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323013#M119008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks all for your replies,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Indeed there was an error with formatting.Since max_dt_val is a date field, it should be in quotes.&lt;/P&gt;&lt;P&gt;&amp;nbsp; In place of&amp;nbsp; &lt;/P&gt;&lt;P&gt;SQL create table abc.newTable as (select log_user_id,login_dt,touch_ti from abc.sample1&lt;/P&gt;&lt;P&gt;where login_dt = $(max_dt_val)) with data;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I used&lt;/P&gt;&lt;P&gt;SQL create table abc.newTable as (select log_user_id,login_dt,touch_ti from abc.sample1&lt;/P&gt;&lt;P&gt;where login_dt = '$(max_dt_val)') with data;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now it is working fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 09:19:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323013#M119008</guid>
      <dc:creator />
      <dc:date>2011-11-16T09:19:48Z</dc:date>
    </item>
    <item>
      <title>Urgent: How to use result set from one SQL , use it as a variable and use it in different query</title>
      <link>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323014#M119009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; One more thing that I want to do is to schedule this entire script to run every day.&lt;/P&gt;&lt;P&gt; Please tell me how to do that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 09:29:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323014#M119009</guid>
      <dc:creator />
      <dc:date>2011-11-16T09:29:00Z</dc:date>
    </item>
    <item>
      <title>Urgent: How to use result set from one SQL , use it as a variable and use it in different query</title>
      <link>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323015#M119010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can run a batch file using windows scheduler:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote" style="overflow-x: scroll;"&gt;&lt;PRE class="notranslate"&gt;"C:\Program Files\QlikView\qv.exe /r C:\testDocument.qvw"&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other way is to use document scheduler (I never used this) which is mentioned in reference manuel&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Reload.png" class="jive-image-thumbnail jive-image" onclick="" src="https://community.qlik.com/legacyfs/online/8657_Reload.png" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kiran.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 10:46:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323015#M119010</guid>
      <dc:creator />
      <dc:date>2011-11-16T10:46:43Z</dc:date>
    </item>
    <item>
      <title>Urgent: How to use result set from one SQL , use it as a variable and use it in different query</title>
      <link>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323016#M119011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Kiran,&lt;/P&gt;&lt;P&gt;Can you please tell where should &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"C:\Program Files\QlikView\qv.exe /r &lt;/P&gt;&lt;P&gt;C:\testDocument.qvw"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;be written.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 11:33:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323016#M119011</guid>
      <dc:creator />
      <dc:date>2011-11-16T11:33:23Z</dc:date>
    </item>
    <item>
      <title>Urgent: How to use result set from one SQL , use it as a variable and use it in different query</title>
      <link>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323017#M119012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Open notepad type it and save it as QVRELOAD.bat. You can use this in windows scheduler.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kiran.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 15:56:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Urgent-How-to-use-result-set-from-one-SQL-use-it-as-a-variable/m-p/323017#M119012</guid>
      <dc:creator />
      <dc:date>2011-11-16T15:56:22Z</dc:date>
    </item>
  </channel>
</rss>

