Results 1 to 2 of 2
  1. #1
    Join Date
    May 2002
    Posts
    12

    Unanswered: Db2 Trigger & User ID

    Is there a way to get User ID of the people and use that UserID in DB2 trigger?

    For ex:

    I have the following 2 tables:

    Job_Type:

    Job_Type_Id: char(1)
    Job_Type_desc: varchar(50)
    -----------------------------------
    Job_Type_Hstry:

    Job_Type_Id: char(1)
    Job_Type_desc: varchar(50)
    UserID: char(8)
    Tmstp: timestamp

    and this is the trigger:

    CREATE TRIGGER INSJCODE
    AFTER INSERT ON JOB_TYPE
    REFERENCING NEW AS N
    FOR EACH ROW MODE DB2SQL
    INSERT INTO JOB_TYPE_HSTRY(JOB_TYPE_ID, JOB_TYPE_DESC, USERID, TMSTP)
    VALUES (N.JOB_TYPE_ID, N.JOB_TYPE_DESC,*what to put here for the UserID*, CURRENT_TIMESTAMP)

    Thank you very much for your help.

    HT

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: Db2 Trigger & User ID

    You will have to use USER ... USER is a special register in DB2 which stores the authorization id of the user currently connected ...

    CURRENT TIMESTAMP is also a special register .... BTW, there needs to be a space between the two words and not '_' in your trigger statement ....

    HTH

    Cheers

    Sathyaram


    Originally posted by xauxi
    Is there a way to get User ID of the people and use that UserID in DB2 trigger?

    For ex:

    I have the following 2 tables:

    Job_Type:

    Job_Type_Id: char(1)
    Job_Type_desc: varchar(50)
    -----------------------------------
    Job_Type_Hstry:

    Job_Type_Id: char(1)
    Job_Type_desc: varchar(50)
    UserID: char(8)
    Tmstp: timestamp

    and this is the trigger:

    CREATE TRIGGER INSJCODE
    AFTER INSERT ON JOB_TYPE
    REFERENCING NEW AS N
    FOR EACH ROW MODE DB2SQL
    INSERT INTO JOB_TYPE_HSTRY(JOB_TYPE_ID, JOB_TYPE_DESC, USERID, TMSTP)
    VALUES (N.JOB_TYPE_ID, N.JOB_TYPE_DESC,*what to put here for the UserID*, CURRENT_TIMESTAMP)

    Thank you very much for your help.

    HT

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •