Skip to content

Instantly share code, notes, and snippets.

@renerdias
Created April 23, 2019 21:34
Show Gist options
  • Save renerdias/c4894b00cbb6f8fc0e49b38393593886 to your computer and use it in GitHub Desktop.
Save renerdias/c4894b00cbb6f8fc0e49b38393593886 to your computer and use it in GitHub Desktop.
Funções auxiliares para auditoria
create or replace function auditoria.func_application_name(iprocpid int) returns text as
$body$
declare
tApplicationName text;
begin
select
application_name into tApplicationName
from
pg_stat_activity
where
(pid = iprocpid);
return tApplicationName;
end;
$body$
language 'plpgsql';
create or replace function auditoria.func_application_name() returns text as
$body$
declare
tApplicationName text;
begin
tApplicationName := auditoria.func_application_name(pg_backend_pid());
return tApplicationName;
end;
$body$
language 'plpgsql';
create or replace function auditoria.func_client_hostname(iprocpid int) returns text as
$body$
declare
tClientHostName text;
begin
select
client_hostname into tClientHostName
from
pg_stat_activity
where
(pid = iprocpid);
return tClientHostName;
end;
$body$
language 'plpgsql';
create or replace function auditoria.func_client_hostname() returns text as
$body$
declare
tClientHostName text;
begin
tClientHostName := auditoria.func_client_hostname(pg_backend_pid());
return tClientHostName;
end;
$body$
language 'plpgsql'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment