4 Replies Latest reply: Nov 18, 2012 9:51 PM by DBA112 RSS

    DML - SQL

    DBA112
      Dear SQL Experts,

      I have a table and the update statement as below.

      My table has - UPDATE_USER, UPDATE_DATE columns to record username who is making update and time when the data was updated. How do I modify my SQL stmt to capture update user and update date cols as well? Appreciate your help!!!

      Edited by: Ora DBA on Dec 11, 2012 1:13 AM
        • 1. Re: DML - SQL
          Manguilibe KAO
          Hi,

          It sounds like you want something like:
          UPDATE GLOGOWNER.DRIVER_ASSIGNMENT
           SET
           PREV_DRIVER_ASSIGNMENT_SEQ_NUM = 100,
           UPDATE_USER = <The_user>,
           UPDATE_DATE = <The_date_you_want_here>
           WHERE DRIVER_ASSIGNMENT_SEQ_NO=1;
          • 2. Re: DML - SQL
            ranit B
            This hopefully should do... Not tested.
            UPDATE GLOGOWNER.DRIVER_ASSIGNMENT
            SET  
              PREV_DRIVER_ASSIGNMENT_SEQ_NUM = 100,
              UPDATE_USER = user, -- this holds the current user name
              UPDATE_DATE = sysdate -- holds the current SYSDATE
            WHERE DRIVER_ASSIGNMENT_SEQ_NO=1;
            Check this will clarify...
            select user,sysdate from dual;
            Ranit B.
            • 3. Re: DML - SQL
              sb92075
              UPDATE glogowner.driver_assignment 
              SET    prev_driver_assignment_seq_num = 100, 
                     update_user = USER, 
                     update_date = SYSDATE 
              WHERE  driver_assignment_seq_no = 1; 
              • 4. Re: DML - SQL
                DBA112
                Thanks, I was using single quotes for the USER which was throwing an error earlier. Cleared now.