Current database name

Поиск
Список
Период
Сортировка
Искать

Current database name

От:
Alexander Solianic <solianic@yahoo.com>
Дата:
Hi, Posgres Gurus!

Does anybody know if there's a way to get name of the current
session's database in stored procedure, i.e. something like
CURRENT_USER variable?

Thanks
-- 
Regards,
Alexander Solianic

Re: Current database name

От:
Manuel Sugawara <masm@fciencias.unam.mx>
Дата:
Alexander Solianic  writes:

> Hi, Posgres Gurus!
> 
> Does anybody know if there's a way to get name of the current
> session's database in stored procedure, i.e. something like
> CURRENT_USER variable?

what's wrong with current_user?

create function my_user() returns text as '
declare
  var_res text;
begin
  select current_user into var_res;
  return var_res;
end;
' language 'plpgsql';

regression=# select my_func();
 my_func 
---------
 masm
(1 row)

hth,
Manuel.

Re: Current database name

От:
Alexander Solianic <solianic@yahoo.com>
Дата:
Manuel Sugawara wrote:

> Alexander Solianic  writes:
> 
>> Hi, Posgres Gurus!
>> 
>> Does anybody know if there's a way to get name of the current
>> session's database in stored procedure, i.e. something like
>> CURRENT_USER variable?
> 
> what's wrong with current_user?

nothing wrong with it, but I asked "is there a function/variable similar
to CURRENT_USER, SESSION_USER etc, that returns the name of the
current (connected) *database*".

-- 
Regards,
Alexander Solianic
FAQ