<?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 SQL Statement stored in another table in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-SQL-Statement-stored-in-another-table/m-p/201237#M59433</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to load a SQL which is stored in a column called statement of another Table.&lt;/P&gt;&lt;P&gt;The output from all SQL statements in the table needs to be concatenated.&lt;/P&gt;&lt;P&gt;I am using the following code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[ code ]&lt;/P&gt;&lt;P&gt;ODBC CONNECT TO XXXXX;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;[SQLCODE]:&lt;BR /&gt;LOAD `sqlcode`,&lt;BR /&gt; statement,&lt;BR /&gt; title,&lt;BR /&gt; description,&lt;BR /&gt; dropoffpct,&lt;BR /&gt; avgsettlevalue,&lt;BR /&gt; avgpctcomp;&lt;BR /&gt;SQL SELECT *&lt;BR /&gt;FROM misql;&lt;BR /&gt;&lt;BR /&gt;LET vLoop=noofrows('SQLCODE');&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;FOR i = 0 to $(vLoop)-1&lt;BR /&gt; LET vSQL = peek('statement',$(i),SQLCODE);&lt;BR /&gt; SQL $(vSQL);&lt;BR /&gt;NEXT i&lt;/P&gt;&lt;P&gt;[ /code ]&lt;/P&gt;&lt;P&gt;---------------------------------------&lt;BR /&gt;Error Msg&lt;BR /&gt;---------------------------------------&lt;BR /&gt;ODBC read failed&lt;BR /&gt;SQL SELECT *&lt;BR /&gt;FROM midata d, mirejections r&lt;BR /&gt;WHERE d.archstatus = 'Live'&lt;BR /&gt;AND d.rejectedreasons = r.type&lt;BR /&gt;AND d.claimtypedesc LIKE '%fast track%'&lt;BR /&gt;AND d.dmclaimtypedesc LIKE '%car accident%'&lt;BR /&gt;AND r.wipinc = '1'&lt;BR /&gt;AND d.feeearnerdesc NOT&lt;BR /&gt;IN (&lt;BR /&gt;'Allocation Manager PI', 'Allocation Manager SM'&lt;BR /&gt;)&lt;BR /&gt;AND d.feteamname NOT&lt;BR /&gt;IN (&lt;BR /&gt;'Assessment Team', 'Hera'&lt;BR /&gt;)&lt;BR /&gt;ORDER BY d.fileopened DESC&lt;BR /&gt;---------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What could be going wrong?&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Apr 2010 13:07:57 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-04-02T13:07:57Z</dc:date>
    <item>
      <title>Using SQL Statement stored in another table</title>
      <link>https://community.qlik.com/t5/QlikView/Using-SQL-Statement-stored-in-another-table/m-p/201237#M59433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to load a SQL which is stored in a column called statement of another Table.&lt;/P&gt;&lt;P&gt;The output from all SQL statements in the table needs to be concatenated.&lt;/P&gt;&lt;P&gt;I am using the following code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[ code ]&lt;/P&gt;&lt;P&gt;ODBC CONNECT TO XXXXX;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;[SQLCODE]:&lt;BR /&gt;LOAD `sqlcode`,&lt;BR /&gt; statement,&lt;BR /&gt; title,&lt;BR /&gt; description,&lt;BR /&gt; dropoffpct,&lt;BR /&gt; avgsettlevalue,&lt;BR /&gt; avgpctcomp;&lt;BR /&gt;SQL SELECT *&lt;BR /&gt;FROM misql;&lt;BR /&gt;&lt;BR /&gt;LET vLoop=noofrows('SQLCODE');&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;FOR i = 0 to $(vLoop)-1&lt;BR /&gt; LET vSQL = peek('statement',$(i),SQLCODE);&lt;BR /&gt; SQL $(vSQL);&lt;BR /&gt;NEXT i&lt;/P&gt;&lt;P&gt;[ /code ]&lt;/P&gt;&lt;P&gt;---------------------------------------&lt;BR /&gt;Error Msg&lt;BR /&gt;---------------------------------------&lt;BR /&gt;ODBC read failed&lt;BR /&gt;SQL SELECT *&lt;BR /&gt;FROM midata d, mirejections r&lt;BR /&gt;WHERE d.archstatus = 'Live'&lt;BR /&gt;AND d.rejectedreasons = r.type&lt;BR /&gt;AND d.claimtypedesc LIKE '%fast track%'&lt;BR /&gt;AND d.dmclaimtypedesc LIKE '%car accident%'&lt;BR /&gt;AND r.wipinc = '1'&lt;BR /&gt;AND d.feeearnerdesc NOT&lt;BR /&gt;IN (&lt;BR /&gt;'Allocation Manager PI', 'Allocation Manager SM'&lt;BR /&gt;)&lt;BR /&gt;AND d.feteamname NOT&lt;BR /&gt;IN (&lt;BR /&gt;'Assessment Team', 'Hera'&lt;BR /&gt;)&lt;BR /&gt;ORDER BY d.fileopened DESC&lt;BR /&gt;---------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What could be going wrong?&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Apr 2010 13:07:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-SQL-Statement-stored-in-another-table/m-p/201237#M59433</guid>
      <dc:creator />
      <dc:date>2010-04-02T13:07:57Z</dc:date>
    </item>
    <item>
      <title>Using SQL Statement stored in another table</title>
      <link>https://community.qlik.com/t5/QlikView/Using-SQL-Statement-stored-in-another-table/m-p/201238#M59434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It would help to see what is in vSQL when it fails.&lt;/P&gt;&lt;P&gt;I'm guessing that when you are passing through the SQL - you have a SQL SQL Select going.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Apr 2010 17:45:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-SQL-Statement-stored-in-another-table/m-p/201238#M59434</guid>
      <dc:creator />
      <dc:date>2010-04-02T17:45:36Z</dc:date>
    </item>
    <item>
      <title>Using SQL Statement stored in another table</title>
      <link>https://community.qlik.com/t5/QlikView/Using-SQL-Statement-stored-in-another-table/m-p/201239#M59435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-weight: bold"&gt;&lt;/P&gt;&lt;PRE class="jive_text_macro jive_macro_quote" jivemacro="quote"&gt;&lt;B&gt;&lt;BR /&gt;wshpuntoff wrote:&lt;BR /&gt;&lt;BR /&gt;It would help to see what is in vSQL when it fails.&lt;BR /&gt;&lt;BR /&gt; I'm guessing that when you are passing through the SQL - you have a SQL SQL Select going.&lt;BR /&gt;&lt;/B&gt; &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/PRE&gt;&lt;B&gt;&lt;BR /&gt;&lt;/B&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks... but it seems issue is with the SQL. (the one given in ERROR message.&lt;/P&gt;&lt;P&gt;when I run that statement directly in MySQL it s running fine. I tried running it Directly in Script, still it gves the same error in Qlikview.&lt;/P&gt;&lt;P&gt;Other simple queries are running fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Apr 2010 09:31:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-SQL-Statement-stored-in-another-table/m-p/201239#M59435</guid>
      <dc:creator />
      <dc:date>2010-04-05T09:31:08Z</dc:date>
    </item>
    <item>
      <title>Using SQL Statement stored in another table</title>
      <link>https://community.qlik.com/t5/QlikView/Using-SQL-Statement-stored-in-another-table/m-p/201240#M59436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Does this part run?&lt;/P&gt;&lt;P&gt;SQL SELECT *&lt;BR /&gt;FROM midata d, mirejections r&lt;/P&gt;&lt;P&gt;I'm thinking the problem might be the column names here. Try encapsulating them in " " or [ ], "midata d" for example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Apr 2010 09:59:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-SQL-Statement-stored-in-another-table/m-p/201240#M59436</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-04-05T09:59:58Z</dc:date>
    </item>
  </channel>
</rss>

