4 Replies Latest reply on Jun 22, 2012 3:08 AM by 682000

    Which trigger should be used?

    682000
      Hi exports,
      I have a multi records tublar data block. there is a colum called expiry_date. The logic is:

      1 In sert mode, this colum is protected and null values will be saved into the database.
      2. In update mode, when user click "Expiry_date" colum, this colum is automatically populated with system date


      Could you advise what's the best way to code this logic?


      Thanks in advance for the help!


      Michael
        • 1. Re: Which trigger should be used?
          LT.ora
          try Pre-Text-Item it Perform an action before Form Builder navigates to a text item from the record level.

          IF :System.Record_Status ='CHANGED' THEN -- you can also try NOT NEW :System.Record_Status
          :expiry_date:=sysdate;
          end if;
          • 2. Re: Which trigger should be used?
            Prabodh
            Hi,
            >
            I have a multi records tublar data block. there is a colum called expiry_date. The logic is:

            1 In sert mode, this colum is protected and null values will be saved into the database.
            2. In update mode, when user click "Expiry_date" colum, this colum is automatically populated with system date

            Could you advise what's the best way to code this logic?
            >

            If Expiry_date is anyway not to be entered by a user then why do you need it on the Form as displayed/enterable item? It should be hidden. And you should write a Before Update For Each Row trigger on the table to set :NEW.EXPIRY_DATE := SYSDATE.

            Regards,
            1 person found this helpful
            • 3. Re: Which trigger should be used?
              Amatu Allah Neveen Ebrahim
              Hi Michael

              ON-INSERT Trigger or PRE-INSERT Trigger
              :expiry_date := ' ' ;
              there is No UPDATE MODE u can use ....

              ON-UPDATE Trigger or PRE-UPDATE Trigger but this is not exactly what u want to do but may be an initial step
              :expiry_date := SYSDATE;
              or
              IF :SYSTEM_MODE  != 'INSERT' THEN
              
              :expiry_date := SYSDATE;
              
              END IF;
              Not tested....

              Hope this helps...

              Regards,

              Amatu Allah

              Edited by: Amatu Allah on Jun 21, 2012 12:05 AM
              1 person found this helpful
              • 4. Re: Which trigger should be used?
                682000
                Hi expert,

                I have taken your advice and put code in Pre-Text-Itemtrigger and it works fine most of time. But there is one issue with this Pre-Text-Item trigger.

                When I update expiry_date and set it to null again and save it. The null value actually saved into database but Pre-Text-Item trigger fires again and automatcally populates expiry_date with sysdate again, which makes user think sysdate is the value for expiry_date
                in the database.

                Could you please advise how I can fix this issue?

                Thanks in advance!!


                Michael