5 Replies Latest reply: Dec 4, 2013 10:55 AM by MVM RSS

    Trigger

    Moazam Shareef

      I have two date column date-1 and date2 on a tubular block which trigger i have to use to insert date-1 data into date2 column with below format?

       

      BLK.DATE2:=TO_DATE('BLK.DATE-1', 'DD-MON-YYYY');

       

       

      Regards

        • 1. Re: Trigger
          MLBrown

          If both items are defined as dates then you do not need to use the TO_DATE function.  Also, don't use "-1" since that means subtract 1.  Use an underscore instead.  With that said your logic would look something like this:

           

          :BLK.DATE2 := :BLK.DATE_1;

          • 2. Re: Trigger
            MVM

            Hi,

             

            Both date fields DATE_1 and DATE2 should have datatype as DATE and apply the format mask in property palette as 'DD-MON-YYYY' / 'DD-MON-RRRR'.

             

            Now if you are entering date in DATE_1 field and want to have same in DATE2, you can do the assignment

            :BLK.DATE2 := :BLK.DATE_1;

            on when-validate-item trigger of BLK.DATE_1.

            This is better if you are showing both date fields on screen.

             

            If DATE2 is hidden, you can have the assignment on PRE-INSERT trigger of BLK datablock.

             

            This will ensure that you are inserting same value in date fields.

             

            Another method is use synchronize with item property for DATE2.

             

            Hope this helps.

            • 3. Re: Trigger
              Moazam Shareef

              Thanks MVM.

              I import data from excel to forms i took date data as char into date1 which import sucessfully i want to convert those import date data into another item which is date datatype i tried the below codes on PRE-INSERT block level trigger but fail to achieve.

              :BLK.DATE:=:BLK.DATE1

              :BLK.DATE:=TO_DATE('BLK.DATE1', 'DD/MON/YYY');

              SELECT BLK.DATE1 INTO :BLK.DATE FROM DUAL;

              how can i achive the task.

              • 4. Re: Trigger
                Priyasagi

                :blk.date:=to_date(:blk_date1,'DD-MON-YYYY');

                • 5. Re: Trigger
                  MVM

                  Hi,

                   

                  When importing date data as char - import it into a new item BLK.DATE1_CHAR, ensure that BLK.DATE1_CHAR is CHAR item and Non-database item.

                   

                  The item BLK.DATE1 is DATE item and Database item and having format mask 'DD/MON/YYY'

                  And BLK.DATE is ofcourse DATE item and Database item and having format mask 'DD/MON/YYY'

                   

                  Now on PRE-INSERT of BLK block, do the following:

                   

                  :BLK.DATE1:=TO_DATE('BLK.DATE1_CHAR', 'DD/MON/YYY'); -- CHAR data to DATE and assign to DATE

                  :BLK.DATE:=:BLK.DATE1;-- copy DATE to another DATE;

                   

                  This will ensure that you are inserting DATE in date fields (Note: DATE1 and DATE are columns in table with DATE datatype)

                   

                  I dont understand the purpose of your last SELECT statement. Please explain.