In PostgreSQL scripts, you can use global variables by defining custom variables and using them within your SQL code.
Example:
-- set a global variable
SET my_var = 42;-- use the global variable SELECT * FROM my_table WHERE column = my_var;-- unset the global variable
RESET my_var;