5 Replies Latest reply: Nov 27, 2012 3:29 AM by Christian Conejero RSS

    Temp Table in Macro

      Hi Guys can i create a temp table inside a macro .... ??? i do not want to make  it in Qlikview Data model or in some other database. Just want to store some values in a field ????? Or may be can i store the values in some field using macro

        • Re: Temp Table in Macro
          Christian Conejero

          Yes it's possible to modify QV data model tables with a macro.

          You also can use variables from the variable panel in the macro module.

           

          Rem Dynamic Data Update

          sub Update
            SET Result = ActiveDocument.DynamicUpdateCommand ("UPDATE * SET Discount = if(Discount >= 35, 0, if (City='Stockholm', Discount + 5, Discount + 2)) WHERE Country = 'SE'")
            if Result = false then
              MsgBox Result.ErrorMessage
            end if 
          end sub

          sub Insert
            SET Result = ActiveDocument.DynamicUpdateCommand ("INSERT INTO * (Country, City) VALUES (DK, Copenhagen), (NO, Oslo)")
            if Result = false then
              MsgBox Result.ErrorMessage
            end if 
          end sub

          sub Delete
            SET Result = ActiveDocument.DynamicUpdateCommand ("DELETE FROM CITY WHERE IsNull (Discount)")
            if Result = false then
              MsgBox Result.ErrorMessage
            end if 
          end sub

           

           

          You need the APIGuide.

           

          DataUpdate.jpg

          • Re: Temp Table in Macro
            Christian Conejero

            also, you can load a table from anywhere and then state the clause:

             

            Drop Table TableName;

            Drop field from table ...;

            Drop fields ...; Drop Tables ...;

            in the script.