Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

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

5 Replies
christian77
Valued Contributor

Re: Temp Table in Macro

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

christian77
Valued Contributor

Re: Temp Table in Macro

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.

Not applicable

Re: Temp Table in Macro

Hi Christian

Thanks for the quick reply but still the field is not getting updated ....

am i missing something .. ??????

Not applicable

Re: Temp Table in Macro

Hey Christan

I am able to update the field but when i am doing a refersh .. the value is getting back to the old value...

but i do not want that .. is it possible???

christian77
Valued Contributor

Re: Temp Table in Macro

Ok. Refresh means reload. Of course, what did you expect with a new reload?

Listen,

When you update your table, export it to a qvd or txt or whatever in the same macro.

You can export only what you want and concatenate in the next refresh (reload)

luck

Community Browser