<?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: variables in sql in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987294#M336650</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sasi;&lt;/P&gt;&lt;P&gt;I have the sql script in a text file, called CUSTOMER.sql&lt;/P&gt;&lt;P&gt;I call it in the qlikview script of many files qvw with the next sentence: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL $(Include=CUSTOMER.sql);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to use the variable vDocumentName in the sql script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;I hope I have explained well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Fernando&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Sep 2015 13:56:03 GMT</pubDate>
    <dc:creator />
    <dc:date>2015-09-07T13:56:03Z</dc:date>
    <item>
      <title>variables in sql</title>
      <link>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987288#M336644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to execute an sql script using a qlikview variable. I explain what I want with an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a qvw file called MyQVW.QVW with the variable named vDocumentName with the value DocumentName()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script calls a SQL file:&lt;/P&gt;&lt;P&gt;CUSTOMER:&lt;/P&gt;&lt;P&gt;SQL $(Include=CUSTOMER.sql);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the SQL file "CUSTOMER.sql" I want to use the variable vDocumentName like this way, because I use this SQL file in many QVW and I only want that return values when the QVW is MyQVW.QVW:&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;FROM tb_Customers&lt;/P&gt;&lt;P&gt;WHERE 'MyQVW.QVW'='$(vDocumentName)'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script doesn't do what I want. If I use '$(vDocumentName)' in a field of the SQL file (EJ: TEST='$(vDocumentName)') returns correctly the value of the name of the file but when I use it in an expression "'MyQVW.QVW'='$(vDocumentName)'" this doesn't go well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Someone knows what happens in my script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Fernando&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2015 10:12:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987288#M336644</guid>
      <dc:creator />
      <dc:date>2015-09-07T10:12:29Z</dc:date>
    </item>
    <item>
      <title>Re: variables in sql</title>
      <link>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987289#M336645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT *&lt;BR /&gt; &lt;BR /&gt; FROM $(vDocumentName)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let me know&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2015 10:34:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987289#M336645</guid>
      <dc:creator>alexandros17</dc:creator>
      <dc:date>2015-09-07T10:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: variables in sql</title>
      <link>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987290#M336646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May be Try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if DocumentName()='MyQVW.QVW'&lt;/P&gt;&lt;P&gt;tab1:&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FROM tb_Customers;&lt;/P&gt;&lt;P&gt;end if&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2015 10:45:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987290#M336646</guid>
      <dc:creator>sasiparupudi1</dc:creator>
      <dc:date>2015-09-07T10:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: variables in sql</title>
      <link>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987291#M336647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Alessandro;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is not what I want. I want to do a select from tb_Customers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Fernando&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2015 10:52:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987291#M336647</guid>
      <dc:creator />
      <dc:date>2015-09-07T10:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: variables in sql</title>
      <link>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987292#M336648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sashidar;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SQL file is a UNION of many SELECTs. In this select only have to return values if the document is MyQVW.&lt;/P&gt;&lt;P&gt;I need to have the SQL Script in a file and call it with an include sentence of QlikView.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This solution is not for my problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Fernando&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2015 10:56:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987292#M336648</guid>
      <dc:creator />
      <dc:date>2015-09-07T10:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: variables in sql</title>
      <link>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987293#M336649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can you please post a sample app with your sql file?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure if it is your expectation to write qv script in a text file? if it is then it is not going to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sasi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2015 12:59:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987293#M336649</guid>
      <dc:creator>sasiparupudi1</dc:creator>
      <dc:date>2015-09-07T12:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: variables in sql</title>
      <link>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987294#M336650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sasi;&lt;/P&gt;&lt;P&gt;I have the sql script in a text file, called CUSTOMER.sql&lt;/P&gt;&lt;P&gt;I call it in the qlikview script of many files qvw with the next sentence: &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL $(Include=CUSTOMER.sql);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to use the variable vDocumentName in the sql script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;I hope I have explained well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Fernando&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2015 13:56:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987294#M336650</guid>
      <dc:creator />
      <dc:date>2015-09-07T13:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: variables in sql</title>
      <link>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987295#M336651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have a SQL problem here. If I understand you well, sometimes you do want the SELECT from Customers to return rows by adding something like ...WHERE 1 = 1 (simplified) and at other times you do not want the SELECT from Customers to return rows by saying something like ... WHERE 1 = 0. Which works perfectly in a QlikView LOAD statement but aparently not in SQL. Right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2015 14:44:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987295#M336651</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2015-09-07T14:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: variables in sql</title>
      <link>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987296#M336652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Peter;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wanted to simplify the SQL script because I thought that would be easier to understand the problem but got the opposite effect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My SQL have many conditions and many joins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Really I want to do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;FROM table1 as t1&lt;/P&gt;&lt;P&gt;INNER JOIN table2 as t2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ON t1.id=....&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;WHERE condition1=true&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and condition2 =false&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and ( (&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;'MyQVW.QVW'&amp;lt;&amp;gt;'$(vDocumentName)')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OR&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (t1.Date &amp;gt;= '07/09/2015')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the QVW file is MyQVW.QVW the condition have to evaluate the condition t1.Date &amp;gt;= '07/09/2015' and only will give me the data of today&lt;/P&gt;&lt;P&gt;If the QVW file isn't MyQVW.QVW the condition is always true and don't will evaluate the condition t1.Date &amp;gt;= '07/09/2015' and will give me all of data&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;But &lt;SPAN style="font-size: 13.3333px;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;'MyQVW.QVW'&amp;lt;&amp;gt;'$(vDocumentName)' don't return the expected result.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Fernando&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2015 15:06:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/variables-in-sql/m-p/987296#M336652</guid>
      <dc:creator />
      <dc:date>2015-09-07T15:06:25Z</dc:date>
    </item>
  </channel>
</rss>

