The following code works fine in my python IDE:
counter = 1000
def increment():
global counter
counter += 1
increment()
print(counter)
But when I copy and paste the code in a pl/python function (as below), it doesn't work.
counter = 1000
def increment():
global counter
counter += 1
increment()
plpy.notice(counter)
The error message returned is:
ERROR: NameError: name 'counter' is not defined
CONTEXT: Traceback (most recent call last):
PL/Python function "testing", line 9, in <module>
increment()
PL/Python function "testing", line 6, in increment
counter += 1
PL/Python function "testing"