Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

DynamicUpdateCommand

Hello,

Sorry if this has been asked before but I am having a problem with the DynamicUpdateCommand,

I am trying to update a field called value to it's value + 1, eventually it will be more complicated than this but I cannot get even this basic operation to work.

My code inside a macro is:

sub Update

set result1 = ActiveDocument.DynamicUpdateCommand ("UPDATE * SET Value = Value + 1 Where IDVal = 'CC_145'")

End Sub

this does nothing, however if I remove the Value + parts it does update to 1:

sub Update

set result1 = ActiveDocument.DynamicUpdateCommand ("UPDATE * SET Value = 1 Where IDVal = 'CC_145'")

End Sub

The above does work does not achieve what we need.

Any help would be great!

Many Thanks,
Chris

1 Solution

Accepted Solutions
nstefaniuk
Not applicable

DynamicUpdateCommand

Hi. Try with this module :

sub increaseValue

vChosenId = ActiveDocument.GetVariable("vChosenId").GetContent.String

vChosenIdValue = CInt(ActiveDocument.GetVariable("vChosenIdValue").GetContent.String)

query="UPDATE Data SET value = "&vChosenIdValue+1&" Where id = '"&vChosenId&"'"

set sqlerror=ActiveDocument.DynamicUpdateCommand(query)

if (sqlerror = false) then ' send message when error

MsgBox sqlerror.ErrorMessage

exit sub

end if

end sub

And create 2 variables : 1 which store the chosen id and 1 which store the value for the chosen id (easy to create with function Only and a Set Analysis)

4 Replies
IAMDV
Not applicable

Re: DynamicUpdateCommand

Hi Chris,

Which version of QV are you using? Please can you post the sample document? It will be easy for me to test.

Thanks - DV

www.qlikshare.com

Not applicable

DynamicUpdateCommand

Hi DV,

Thanks for your reply. I have added my development file to the question.

I am using QV 10 SR3.

Thanks again for any help you can offer,

Chris

Not applicable

DynamicUpdateCommand

Hi,

I wondered if anyone could help with this and I am still confused as to what I am doing wrong?

Thanks!

Chris

nstefaniuk
Not applicable

DynamicUpdateCommand

Hi. Try with this module :

sub increaseValue

vChosenId = ActiveDocument.GetVariable("vChosenId").GetContent.String

vChosenIdValue = CInt(ActiveDocument.GetVariable("vChosenIdValue").GetContent.String)

query="UPDATE Data SET value = "&vChosenIdValue+1&" Where id = '"&vChosenId&"'"

set sqlerror=ActiveDocument.DynamicUpdateCommand(query)

if (sqlerror = false) then ' send message when error

MsgBox sqlerror.ErrorMessage

exit sub

end if

end sub

And create 2 variables : 1 which store the chosen id and 1 which store the value for the chosen id (easy to create with function Only and a Set Analysis)