Using Automation for Dynamic Data Update
Dynamic Data Update provides a mechanism for making transactions with the in-memory data of QlikView in real-time using syntax similar to SQL. The field data is updated in real-time without running the script.
Examples
Example 1: Dynamic Data Update
Rem ** Dynamic Data Update **
sub Update
SET Result = ActiveDocument.DynamicUpdateCommand ("UPDATE * SET Discount = 4 WHERE City = 'Stockholm'")
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
Information noteIt is not possible to use If clauses within the data statement!
Example 2: Non-working example using If clauses
Rem ** This example using If clauses in data statement will not work **
sub UpdateIf
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