<?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: Variável no SQL in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Vari%C3%A1vel-no-SQL/m-p/869297#M658347</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ola Marcos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eu acredito que nao e possivel executar outros comandos SQL atraves do QV como declaracao de variaveis, etc... Talvez voce consiga o resultado que deseja criando uma stored procedure no BD e chamando atraves do QV, lembro de ter visto um post semelhante aqui na comunidade a algum tempo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Abracos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cesar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 May 2015 12:03:22 GMT</pubDate>
    <dc:creator>cesaraccardi</dc:creator>
    <dc:date>2015-05-15T12:03:22Z</dc:date>
    <item>
      <title>Variável no SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Vari%C3%A1vel-no-SQL/m-p/869296#M658346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Olá,&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Eu gostaria de criar algo assim:&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;set vtable = 'TAB01'&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;TABLE&gt;:&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;SQL&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;declare @xtab varchar(500)&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;declare @sql varchar(max)&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;set @xtab= $(vtable)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;Set @sql = 'SELECT * from '+@xtab&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;Exec(@sql);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;Como posso fazer isso?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;Muito obrigado!&lt;/SPAN&gt;&lt;/P&gt;&lt;/TABLE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 11:23:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Vari%C3%A1vel-no-SQL/m-p/869296#M658346</guid>
      <dc:creator />
      <dc:date>2015-05-15T11:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Variável no SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Vari%C3%A1vel-no-SQL/m-p/869297#M658347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ola Marcos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eu acredito que nao e possivel executar outros comandos SQL atraves do QV como declaracao de variaveis, etc... Talvez voce consiga o resultado que deseja criando uma stored procedure no BD e chamando atraves do QV, lembro de ter visto um post semelhante aqui na comunidade a algum tempo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Abracos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cesar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 12:03:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Vari%C3%A1vel-no-SQL/m-p/869297#M658347</guid>
      <dc:creator>cesaraccardi</dc:creator>
      <dc:date>2015-05-15T12:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Variável no SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Vari%C3%A1vel-no-SQL/m-p/869298#M658348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Olá Marcos,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Se fizer pelo script do QlikView &lt;SPAN style="font-size: 13.3333330154419px;"&gt; acredito que &lt;/SPAN&gt;o resultado seja o mesmo;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;SET vTabela = NomeTabela;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;SET vWhere = Where Campo &amp;gt;=&amp;nbsp; 2;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;$(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;vTabela&lt;/SPAN&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;SQL &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;SELECT * FROM $(&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;vTabela&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;) $(vWhere);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Don't worry, be Qlik.&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Tonial.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 13:11:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Vari%C3%A1vel-no-SQL/m-p/869298#M658348</guid>
      <dc:creator>fernando_tonial</dc:creator>
      <dc:date>2015-05-15T13:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Variável no SQL</title>
      <link>https://community.qlik.com/t5/QlikView/Vari%C3%A1vel-no-SQL/m-p/869299#M658349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Consegui deste jeito:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set xpto = '';&lt;/P&gt;&lt;P&gt;let counter = 1;&lt;/P&gt;&lt;P&gt;let xempa = '010060';&lt;/P&gt;&lt;P&gt;do while counter &amp;lt; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp; let xemp = mid($(xempa),1,3);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if $(counter) &amp;gt; 1 then&lt;/P&gt;&lt;P&gt;&amp;nbsp; set xpto = $(xpto) union all&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set xpto = $(xpto) Select top 10 $(counter) as emp, E1_NUM from SE1$(xemp);&lt;/P&gt;&lt;P&gt;&amp;nbsp; Else&lt;/P&gt;&lt;P&gt;&amp;nbsp; set xpto =&amp;nbsp; Select top 10 $(counter) as emp, E1_NUM from SE1$(xemp);&lt;/P&gt;&lt;P&gt;&amp;nbsp; Endif&lt;/P&gt;&lt;P&gt;&amp;nbsp; let counter = counter + 1; &lt;/P&gt;&lt;P&gt;&amp;nbsp; let xempa = mid($(xempa),4,len($(xempa))-3);&lt;/P&gt;&lt;P&gt;loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;teste:&lt;/P&gt;&lt;P&gt;SQL &lt;/P&gt;&lt;P&gt;$(xpto);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Obrigadão a todos!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 May 2015 13:53:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Vari%C3%A1vel-no-SQL/m-p/869299#M658349</guid>
      <dc:creator />
      <dc:date>2015-05-15T13:53:38Z</dc:date>
    </item>
  </channel>
</rss>

