Dear David!
To know - your solution is working well!
*EXECUTE format('SET ROLE %I', variablename); *
Thank you!
bw
dd