Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

context.UpdateVariable

I've read numerous places about how a variable isn't updated until a Python script is done, but it seems I'm confused at how the update happens.

I have a job environment variable named foo. Here it is in text mode:

foo Text Copied Public

I have a one line Python script which has:

context.updateVariable('foo', 'new-value')

After running this script, if I go back and look at my job environment variables, shouldn't foo be updated? Or, if I have a different Python script which has:

print(foo)

and I run it afterward, shouldn't I see my newly assigned value?

3 Community Answers

Matillion Agent  

David Lipowitz —

Hi Quinn,

Thanks for the question. context.updateVariable doesn’t change the default value of the variable but does change it for the life of the session you’re in.

If you look as the task out put does:

    print(foo)

result in seeing the following in the task output?

    new-value

Best Regards,
Dave


Quinn Wildman —

Yes, print(foo) does show new-value in the Python script.

So, if I want to persist a value from a variable, I guess I need to store it in a table?


Matillion Agent  

David Lipowitz —

Hi Quinn,

Yes, persisting variable values in a table works nicely. See also the documentation on our Table Iterator component, as that provides a ready means of loading data from tables into variables: Table Iterator.

Best Regards,
Dave

Post Your Community Answer

To add an answer please login