Re: Current database name

From: Manuel Sugawara <masm(at)fciencias(dot)unam(dot)mx>
To: Alexander Solianic <solianic(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Current database name
Date: 2001-06-05 21:39:55
Message-ID: m3puci38t0.fsf@dep1.fciencias.unam.mx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alexander Solianic <solianic(at)yahoo(dot)com> 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Moo 2001-06-05 21:50:15 Re: [newbie] Relations...
Previous Message Jerzy Kut 2001-06-05 21:37:12 Re: [newbie] Relations...