Tips and Tutorials

Global Variables in Postgresql

Author
Ashvin Gami
1 min read Share

Example:

create or replace function glb(code text)
returns integer language sql as $$
    select coalesce( (select current_setting('glb.'||code,true)::integer), 0);
$$;

set glb.user_not_found to -1;
set glb.user_does_not_have_permission to -2;

select glb('user_not_found'), glb('user_does_not_have_permission');

Click here for more details


Related Articles


View all articles