When trying to run scripts in pgAdmin I wanted the something similar where i wanted to store a value to use across multiple queries. This is what I found which is similar to SQL
set session vars.batch_id = '82';
select * from batches where batch_id = current_setting('vars.batch_id')::int;