Subject Re: [ib-support] current_user?
Author Doug Chamberlin
At 5/22/2001 09:40 AM (Tuesday), richard@... wrote:
>Could anyone tell me, is there some function or variable I can refer
>to within a stored procedure that returns the name of the current
>user?

It is obtained via a built-in global variable named USER. See example below
of an insert trigger which fills in a VARCHAR field named MODUSER with the
name of the current user. (It also fills in the current timestamp the
record was inserted into DATE field named MODDATE.)

CREATE TRIGGER IB0_CARD FOR CARD
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.CARDNUM IS NULL) THEN
NEW.CARDNUM = GEN_ID(CARDNUM_GEN,1);
NEW.STATE = UPPER(NEW.STATE);
NEW.SEARCH = UPPER(NEW.SEARCH);
NEW.SOURCE = UPPER(NEW.SOURCE);
NEW.OWNER = UPPER(NEW.OWNER);
NEW.PRIVATE = UPPER(NEW.PRIVATE);
NEW.ISACTIVE = UPPER(NEW.ISACTIVE);
NEW.MODUSER = USER;
NEW.MODDATE = 'NOW';
END
^