Global Variables in Postgresql


Ashvin Gami

2023-07-27 17:06:56


    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