Thursday, January 12, 2012

INSERT ROW FROM ONE TABLE TO ANOTHER

Hello Friends,

below written query describes us how to insert Data From One table to another in same Schema Database in oracle


INSERT INTO TX_ITEM_IR_TRN_SUB
   (
-- provide all column here of table i.e. TX_ITEM_IR_TRN_SUB
SELECT   T.YEAR,
             T.COMP_CODE,
             T.BRANCH_CODE,
             T.TRN_TYPE,
             T.TRN_NUMB,
             T.PO_COMP_CODE,
             T.PO_BRANCH,
             T.PO_TYPE,
             T.PO_NUMB,
             T.ITEM_CODE,
             T.TRN_QTY,
             0,
             'UnChecked',
             'NA',
             'NA',
             SYSDATE,
             'AKHILESH',
             T.TDATE,
             '0',
             T.NO_OF_UNIT,
             T.UOM_OF_UNIT,
             T.WEIGHT_OF_UNIT
      FROM   TX_ITEM_IR_TRN T
     WHERE   SUBSTR (T.TRN_TYPE, 1, 1) = 'R'
             AND (T.YEAR,
                  T.COMP_CODE,
                  T.BRANCH_CODE,
                  T.TRN_TYPE,
                  T.TRN_NUMB,
                  T.PO_COMP_CODE,
                  T.PO_BRANCH,
                  T.PO_TYPE,
                  T.PO_NUMB,
                  T.ITEM_CODE) NOT IN
                      (SELECT   YEAR,
                                COMP_CODE,
                                BRANCH_CODE,
                                TRN_TYPE,
                                TRN_NUMB,
                                PO_COMP_CODE,
                                PO_BRANCH,
                                PO_TYPE,
                                PO_NUMB,
                                ITEM_CODE
                         FROM   TX_ITEM_IR_TRN_SUB));



No comments:

Post a Comment