Subject | Re: I am a new member |
---|---|
Author | Alexander V.Nevsky |
Post date | 2003-11-11T10:07:40Z |
--- In firebird-support@yahoogroups.com, Carlos J Bracho M
<carlos_bracho_1@u...> wrote:
If I understand you right and you want to know in stored procedure
or trigger who called them, read this, if not - read Alan's post.
There are system variables CURRENT_USER (or simply USER) and
CURRENT_ROLE. In PSQL (stored procedures and triggers language) you
can access them directly like
If (CURRENT_USER='CARLOS') then ...
You can include this variables into your client application queries
too, like
Select Column1, Column2, Current_User
From MyTable
and use as default value in table columns like
Create MyTable
(ID Int Not Null,
Who_Created_Row VarChar(128) Default Current_User)
use roles if you want. If so, you should know what do you want and
specify appropriate role. Anyway, system tables are accessible for
reading for any user and you can connect without role and examine
RDB$ROLES and RDB$USER_PRIVILEGES for roles granted to user.
Best regards,
Alexander.
<carlos_bracho_1@u...> wrote:
> Hi friends...which uses
> I just enjoied this group because I am working in an application
> FireBird like DBMS.into the data
> I read some pdf and they really helped me out.
> But now I have some questions for you:
>
> 1. How can I know the current user? I mean the user who is logged
> base... I have know the username of the current user, how can I knowit?
If I understand you right and you want to know in stored procedure
or trigger who called them, read this, if not - read Alan's post.
There are system variables CURRENT_USER (or simply USER) and
CURRENT_ROLE. In PSQL (stored procedures and triggers language) you
can access them directly like
If (CURRENT_USER='CARLOS') then ...
You can include this variables into your client application queries
too, like
Select Column1, Column2, Current_User
From MyTable
and use as default value in table columns like
Create MyTable
(ID Int Not Null,
Who_Created_Row VarChar(128) Default Current_User)
> 2. When I connect into the database I have to write the role of theuser who
> will log in. "connect data.fdb user yahoo password yahoo role XXX".How can I
> know the user's role without log into the database like sysdba. Imean, I do
> not the role of the user who will log in.Not sure I understand you. You is'nt DUE to specify role, you CAN
use roles if you want. If so, you should know what do you want and
specify appropriate role. Anyway, system tables are accessible for
reading for any user and you can connect without role and examine
RDB$ROLES and RDB$USER_PRIVILEGES for roles granted to user.
> 3. How can I know the system date-time?Answered by Alan.
Best regards,
Alexander.