--====================================================================        
-- Author      : Waqas Yaqoob        
-- Date        : 14-Jun-2017        
-- Description : SP_DML FOR GL_CODE_COMBINATIONS        
--====================================================================        
CREATE PROCEDURE SP_DML_GL_CODE_COMBINATIONS
@CODE_COMBINATION_ID numeric(15),
@LAST_UPDATE_DATE datetime,
@LAST_UPDATED_BY numeric(15),
@CHART_OF_ACCOUNTS_ID numeric(15),
@DETAIL_POSTING_ALLOWED_FLAG varchar(1),
@DETAIL_BUDGETING_ALLOWED_FLAG varchar(1),
@ACCOUNT_TYPE varchar(1),
@ENABLED_FLAG varchar(1),
@SUMMARY_FLAG varchar(1),
@SEGMENT1 varchar(25),
@SEGMENT2 varchar(25),
@SEGMENT3 varchar(25),
@SEGMENT4 varchar(25),
@SEGMENT5 varchar(25),
@SEGMENT6 varchar(25),
@SEGMENT7 varchar(25),
@SEGMENT8 varchar(25),
@SEGMENT9 varchar(25),
@SEGMENT10 varchar(25),
@SEGMENT11 varchar(25),
@SEGMENT12 varchar(25),
@SEGMENT13 varchar(25),
@SEGMENT14 varchar(25),
@SEGMENT15 varchar(25),
@SEGMENT16 varchar(25),
@SEGMENT17 varchar(25),
@SEGMENT18 varchar(25),
@SEGMENT19 varchar(25),
@SEGMENT20 varchar(25),
@SEGMENT21 varchar(25),
@SEGMENT22 varchar(25),
@SEGMENT23 varchar(25),
@SEGMENT24 varchar(25),
@SEGMENT25 varchar(25),
@SEGMENT26 varchar(25),
@SEGMENT27 varchar(25),
@SEGMENT28 varchar(25),
@SEGMENT29 varchar(25),
@SEGMENT30 varchar(25),
@DESCRIPTION varchar(240),
@TEMPLATE_ID numeric(15),
@ALLOCATION_CREATE_FLAG varchar(1),
@START_DATE_ACTIVE datetime,
@END_DATE_ACTIVE datetime,
@ATTRIBUTE1 varchar(150),
@ATTRIBUTE2 varchar(150),
@ATTRIBUTE3 varchar(150),
@ATTRIBUTE4 varchar(150),
@ATTRIBUTE5 varchar(150),
@ATTRIBUTE6 varchar(150),
@ATTRIBUTE7 varchar(150),
@ATTRIBUTE8 varchar(150),
@ATTRIBUTE9 varchar(150),
@ATTRIBUTE10 varchar(150),
@CONTEXT varchar(150),
@SEGMENT_ATTRIBUTE1 varchar(60),
@SEGMENT_ATTRIBUTE2 varchar(60),
@SEGMENT_ATTRIBUTE3 varchar(60),
@SEGMENT_ATTRIBUTE4 varchar(60),
@SEGMENT_ATTRIBUTE5 varchar(60),
@SEGMENT_ATTRIBUTE6 varchar(60),
@SEGMENT_ATTRIBUTE7 varchar(60),
@SEGMENT_ATTRIBUTE8 varchar(60),
@SEGMENT_ATTRIBUTE9 varchar(60),
@SEGMENT_ATTRIBUTE10 varchar(60),
@SEGMENT_ATTRIBUTE11 varchar(60),
@SEGMENT_ATTRIBUTE12 varchar(60),
@SEGMENT_ATTRIBUTE13 varchar(60),
@SEGMENT_ATTRIBUTE14 varchar(60),
@SEGMENT_ATTRIBUTE15 varchar(60),
@SEGMENT_ATTRIBUTE16 varchar(60),
@SEGMENT_ATTRIBUTE17 varchar(60),
@SEGMENT_ATTRIBUTE18 varchar(60),
@SEGMENT_ATTRIBUTE19 varchar(60),
@SEGMENT_ATTRIBUTE20 varchar(60),
@SEGMENT_ATTRIBUTE21 varchar(60),
@SEGMENT_ATTRIBUTE22 varchar(60),
@SEGMENT_ATTRIBUTE23 varchar(60),
@SEGMENT_ATTRIBUTE24 varchar(60),
@SEGMENT_ATTRIBUTE25 varchar(60),
@SEGMENT_ATTRIBUTE26 varchar(60),
@SEGMENT_ATTRIBUTE27 varchar(60),
@SEGMENT_ATTRIBUTE28 varchar(60),
@SEGMENT_ATTRIBUTE29 varchar(60),
@SEGMENT_ATTRIBUTE30 varchar(60),
@SEGMENT_ATTRIBUTE31 varchar(60),
@SEGMENT_ATTRIBUTE32 varchar(60),
@SEGMENT_ATTRIBUTE33 varchar(60),
@SEGMENT_ATTRIBUTE34 varchar(60),
@SEGMENT_ATTRIBUTE35 varchar(60),
@SEGMENT_ATTRIBUTE36 varchar(60),
@SEGMENT_ATTRIBUTE37 varchar(60),
@SEGMENT_ATTRIBUTE38 varchar(60),
@SEGMENT_ATTRIBUTE39 varchar(60),
@SEGMENT_ATTRIBUTE40 varchar(60),
@SEGMENT_ATTRIBUTE41 varchar(60),
@SEGMENT_ATTRIBUTE42 varchar(60),
@REFERENCE1 varchar(1),
@REFERENCE2 varchar(1),
@REFERENCE3 varchar(25),
@REFERENCE4 varchar(1),
@REFERENCE5 varchar(1),
@JGZZ_RECON_FLAG varchar(1),
@JGZZ_RECON_CONTEXT varchar(30),
@PRESERVE_FLAG varchar(1),
@REFRESH_FLAG varchar(1),
@IGI_BALANCED_BUDGET_FLAG varchar(1),
@COMPANY_COST_CENTER_ORG_ID numeric(15),
@REVALUATION_ID numeric(15),
@LEDGER_SEGMENT varchar(20),
@LEDGER_TYPE_CODE varchar(1),
@ALTERNATE_CODE_COMBINATION_ID numeric(15),
@DML_TYPE char(1)
AS        
Begin
          if @DML_TYPE = 'I'        
              Begin        
                   Insert Into GL_CODE_COMBINATIONS        
                   (
                     CODE_COMBINATION_ID,
                     CHART_OF_ACCOUNTS_ID,
                     DETAIL_POSTING_ALLOWED_FLAG,
                     DETAIL_BUDGETING_ALLOWED_FLAG,
                     ACCOUNT_TYPE,
                     ENABLED_FLAG,
                     SUMMARY_FLAG,
                     SEGMENT1,
                     SEGMENT2,
                     SEGMENT3,
                     SEGMENT4,
                     SEGMENT5,
                     SEGMENT6,
                     SEGMENT7,
                     SEGMENT8,
                     SEGMENT9,
                     SEGMENT10,
                     SEGMENT11,
                     SEGMENT12,
                     SEGMENT13,
                     SEGMENT14,
                     SEGMENT15,
                     SEGMENT16,
                     SEGMENT17,
                     SEGMENT18,
                     SEGMENT19,
                     SEGMENT20,
                     SEGMENT21,
                     SEGMENT22,
                     SEGMENT23,
                     SEGMENT24,
                     SEGMENT25,
                     SEGMENT26,
                     SEGMENT27,
                     SEGMENT28,
                     SEGMENT29,
                     SEGMENT30,
                     DESCRIPTION,
                     TEMPLATE_ID,
                     ALLOCATION_CREATE_FLAG,
                     START_DATE_ACTIVE,
                     END_DATE_ACTIVE,
                     ATTRIBUTE1,
                     ATTRIBUTE2,
                     ATTRIBUTE3,
                     ATTRIBUTE4,
                     ATTRIBUTE5,
                     ATTRIBUTE6,
                     ATTRIBUTE7,
                     ATTRIBUTE8,
                     ATTRIBUTE9,
                     ATTRIBUTE10,
                     CONTEXT,
                     SEGMENT_ATTRIBUTE1,
                     SEGMENT_ATTRIBUTE2,
                     SEGMENT_ATTRIBUTE3,
                     SEGMENT_ATTRIBUTE4,
                     SEGMENT_ATTRIBUTE5,
                     SEGMENT_ATTRIBUTE6,
                     SEGMENT_ATTRIBUTE7,
                     SEGMENT_ATTRIBUTE8,
                     SEGMENT_ATTRIBUTE9,
                     SEGMENT_ATTRIBUTE10,
                     SEGMENT_ATTRIBUTE11,
                     SEGMENT_ATTRIBUTE12,
                     SEGMENT_ATTRIBUTE13,
                     SEGMENT_ATTRIBUTE14,
                     SEGMENT_ATTRIBUTE15,
                     SEGMENT_ATTRIBUTE16,
                     SEGMENT_ATTRIBUTE17,
                     SEGMENT_ATTRIBUTE18,
                     SEGMENT_ATTRIBUTE19,
                     SEGMENT_ATTRIBUTE20,
                     SEGMENT_ATTRIBUTE21,
                     SEGMENT_ATTRIBUTE22,
                     SEGMENT_ATTRIBUTE23,
                     SEGMENT_ATTRIBUTE24,
                     SEGMENT_ATTRIBUTE25,
                     SEGMENT_ATTRIBUTE26,
                     SEGMENT_ATTRIBUTE27,
                     SEGMENT_ATTRIBUTE28,
                     SEGMENT_ATTRIBUTE29,
                     SEGMENT_ATTRIBUTE30,
                     SEGMENT_ATTRIBUTE31,
                     SEGMENT_ATTRIBUTE32,
                     SEGMENT_ATTRIBUTE33,
                     SEGMENT_ATTRIBUTE34,
                     SEGMENT_ATTRIBUTE35,
                     SEGMENT_ATTRIBUTE36,
                     SEGMENT_ATTRIBUTE37,
                     SEGMENT_ATTRIBUTE38,
                     SEGMENT_ATTRIBUTE39,
                     SEGMENT_ATTRIBUTE40,
                     SEGMENT_ATTRIBUTE41,
                     SEGMENT_ATTRIBUTE42,
                     REFERENCE1,
                     REFERENCE2,
                     REFERENCE3,
                     REFERENCE4,
                     REFERENCE5,
                     JGZZ_RECON_FLAG,
                     JGZZ_RECON_CONTEXT,
                     PRESERVE_FLAG,
                     REFRESH_FLAG,
                     IGI_BALANCED_BUDGET_FLAG,
                     COMPANY_COST_CENTER_ORG_ID,
                     REVALUATION_ID,
                     LEDGER_SEGMENT,
                     LEDGER_TYPE_CODE,
                     ALTERNATE_CODE_COMBINATION_ID        
                   )
                   Values        
                   (
                    @CODE_COMBINATION_ID,
                    @CHART_OF_ACCOUNTS_ID,
                    @DETAIL_POSTING_ALLOWED_FLAG,
                    @DETAIL_BUDGETING_ALLOWED_FLAG,
                    @ACCOUNT_TYPE,
                    @ENABLED_FLAG,
                    @SUMMARY_FLAG,
                    @SEGMENT1,
                    @SEGMENT2,
                    @SEGMENT3,
                    @SEGMENT4,
                    @SEGMENT5,
                    @SEGMENT6,
                    @SEGMENT7,
                    @SEGMENT8,
                    @SEGMENT9,
                    @SEGMENT10,
                    @SEGMENT11,
                    @SEGMENT12,
                    @SEGMENT13,
                    @SEGMENT14,
                    @SEGMENT15,
                    @SEGMENT16,
                    @SEGMENT17,
                    @SEGMENT18,
                    @SEGMENT19,
                    @SEGMENT20,
                    @SEGMENT21,
                    @SEGMENT22,
                    @SEGMENT23,
                    @SEGMENT24,
                    @SEGMENT25,
                    @SEGMENT26,
                    @SEGMENT27,
                    @SEGMENT28,
                    @SEGMENT29,
                    @SEGMENT30,
                    @DESCRIPTION,
                    @TEMPLATE_ID,
                    @ALLOCATION_CREATE_FLAG,
                    @START_DATE_ACTIVE,
                    @END_DATE_ACTIVE,
                    @ATTRIBUTE1,
                    @ATTRIBUTE2,
                    @ATTRIBUTE3,
                    @ATTRIBUTE4,
                    @ATTRIBUTE5,
                    @ATTRIBUTE6,
                    @ATTRIBUTE7,
                    @ATTRIBUTE8,
                    @ATTRIBUTE9,
                    @ATTRIBUTE10,
                    @CONTEXT,
                    @SEGMENT_ATTRIBUTE1,
                    @SEGMENT_ATTRIBUTE2,
                    @SEGMENT_ATTRIBUTE3,
                    @SEGMENT_ATTRIBUTE4,
                    @SEGMENT_ATTRIBUTE5,
                    @SEGMENT_ATTRIBUTE6,
                    @SEGMENT_ATTRIBUTE7,
                    @SEGMENT_ATTRIBUTE8,
                    @SEGMENT_ATTRIBUTE9,
                    @SEGMENT_ATTRIBUTE10,
                    @SEGMENT_ATTRIBUTE11,
                    @SEGMENT_ATTRIBUTE12,
                    @SEGMENT_ATTRIBUTE13,
                    @SEGMENT_ATTRIBUTE14,
                    @SEGMENT_ATTRIBUTE15,
                    @SEGMENT_ATTRIBUTE16,
                    @SEGMENT_ATTRIBUTE17,
                    @SEGMENT_ATTRIBUTE18,
                    @SEGMENT_ATTRIBUTE19,
                    @SEGMENT_ATTRIBUTE20,
                    @SEGMENT_ATTRIBUTE21,
                    @SEGMENT_ATTRIBUTE22,
                    @SEGMENT_ATTRIBUTE23,
                    @SEGMENT_ATTRIBUTE24,
                    @SEGMENT_ATTRIBUTE25,
                    @SEGMENT_ATTRIBUTE26,
                    @SEGMENT_ATTRIBUTE27,
                    @SEGMENT_ATTRIBUTE28,
                    @SEGMENT_ATTRIBUTE29,
                    @SEGMENT_ATTRIBUTE30,
                    @SEGMENT_ATTRIBUTE31,
                    @SEGMENT_ATTRIBUTE32,
                    @SEGMENT_ATTRIBUTE33,
                    @SEGMENT_ATTRIBUTE34,
                    @SEGMENT_ATTRIBUTE35,
                    @SEGMENT_ATTRIBUTE36,
                    @SEGMENT_ATTRIBUTE37,
                    @SEGMENT_ATTRIBUTE38,
                    @SEGMENT_ATTRIBUTE39,
                    @SEGMENT_ATTRIBUTE40,
                    @SEGMENT_ATTRIBUTE41,
                    @SEGMENT_ATTRIBUTE42,
                    @REFERENCE1,
                    @REFERENCE2,
                    @REFERENCE3,
                    @REFERENCE4,
                    @REFERENCE5,
                    @JGZZ_RECON_FLAG,
                    @JGZZ_RECON_CONTEXT,
                    @PRESERVE_FLAG,
                    @REFRESH_FLAG,
                    @IGI_BALANCED_BUDGET_FLAG,
                    @COMPANY_COST_CENTER_ORG_ID,
                    @REVALUATION_ID,
                    @LEDGER_SEGMENT,
                    @LEDGER_TYPE_CODE,
                    @ALTERNATE_CODE_COMBINATION_ID        
                   )        
              End
          Else if @DML_TYPE = 'U'        
              Begin        
                   Update GL_CODE_COMBINATIONS        
                     Set
                       CODE_COMBINATION_ID  =   @CODE_COMBINATION_ID,
                       LAST_UPDATE_DATE  =   @LAST_UPDATE_DATE,
                       LAST_UPDATED_BY  =   @LAST_UPDATED_BY,
                       CHART_OF_ACCOUNTS_ID  =   @CHART_OF_ACCOUNTS_ID,
                       DETAIL_POSTING_ALLOWED_FLAG  =   @DETAIL_POSTING_ALLOWED_FLAG,
                       DETAIL_BUDGETING_ALLOWED_FLAG  =   @DETAIL_BUDGETING_ALLOWED_FLAG,
                       ACCOUNT_TYPE  =   @ACCOUNT_TYPE,
                       ENABLED_FLAG  =   @ENABLED_FLAG,
                       SUMMARY_FLAG  =   @SUMMARY_FLAG,
                       SEGMENT1  =   @SEGMENT1,
                       SEGMENT2  =   @SEGMENT2,
                       SEGMENT3  =   @SEGMENT3,
                       SEGMENT4  =   @SEGMENT4,
                       SEGMENT5  =   @SEGMENT5,
                       SEGMENT6  =   @SEGMENT6,
                       SEGMENT7  =   @SEGMENT7,
                       SEGMENT8  =   @SEGMENT8,
                       SEGMENT9  =   @SEGMENT9,
                       SEGMENT10  =   @SEGMENT10,
                       SEGMENT11  =   @SEGMENT11,
                       SEGMENT12  =   @SEGMENT12,
                       SEGMENT13  =   @SEGMENT13,
                       SEGMENT14  =   @SEGMENT14,
                       SEGMENT15  =   @SEGMENT15,
                       SEGMENT16  =   @SEGMENT16,
                       SEGMENT17  =   @SEGMENT17,
                       SEGMENT18  =   @SEGMENT18,
                       SEGMENT19  =   @SEGMENT19,
                       SEGMENT20  =   @SEGMENT20,
                       SEGMENT21  =   @SEGMENT21,
                       SEGMENT22  =   @SEGMENT22,
                       SEGMENT23  =   @SEGMENT23,
                       SEGMENT24  =   @SEGMENT24,
                       SEGMENT25  =   @SEGMENT25,
                       SEGMENT26  =   @SEGMENT26,
                       SEGMENT27  =   @SEGMENT27,
                       SEGMENT28  =   @SEGMENT28,
                       SEGMENT29  =   @SEGMENT29,
                       SEGMENT30  =   @SEGMENT30,
                       DESCRIPTION  =   @DESCRIPTION,
                       TEMPLATE_ID  =   @TEMPLATE_ID,
                       ALLOCATION_CREATE_FLAG  =   @ALLOCATION_CREATE_FLAG,
                       START_DATE_ACTIVE  =   @START_DATE_ACTIVE,
                       END_DATE_ACTIVE  =   @END_DATE_ACTIVE,
                       ATTRIBUTE1  =   @ATTRIBUTE1,
                       ATTRIBUTE2  =   @ATTRIBUTE2,
                       ATTRIBUTE3  =   @ATTRIBUTE3,
                       ATTRIBUTE4  =   @ATTRIBUTE4,
                       ATTRIBUTE5  =   @ATTRIBUTE5,
                       ATTRIBUTE6  =   @ATTRIBUTE6,
                       ATTRIBUTE7  =   @ATTRIBUTE7,
                       ATTRIBUTE8  =   @ATTRIBUTE8,
                       ATTRIBUTE9  =   @ATTRIBUTE9,
                       ATTRIBUTE10  =   @ATTRIBUTE10,
                       CONTEXT  =   @CONTEXT,
                       SEGMENT_ATTRIBUTE1  =   @SEGMENT_ATTRIBUTE1,
                       SEGMENT_ATTRIBUTE2  =   @SEGMENT_ATTRIBUTE2,
                       SEGMENT_ATTRIBUTE3  =   @SEGMENT_ATTRIBUTE3,
                       SEGMENT_ATTRIBUTE4  =   @SEGMENT_ATTRIBUTE4,
                       SEGMENT_ATTRIBUTE5  =   @SEGMENT_ATTRIBUTE5,
                       SEGMENT_ATTRIBUTE6  =   @SEGMENT_ATTRIBUTE6,
                       SEGMENT_ATTRIBUTE7  =   @SEGMENT_ATTRIBUTE7,
                       SEGMENT_ATTRIBUTE8  =   @SEGMENT_ATTRIBUTE8,
                       SEGMENT_ATTRIBUTE9  =   @SEGMENT_ATTRIBUTE9,
                       SEGMENT_ATTRIBUTE10  =   @SEGMENT_ATTRIBUTE10,
                       SEGMENT_ATTRIBUTE11  =   @SEGMENT_ATTRIBUTE11,
                       SEGMENT_ATTRIBUTE12  =   @SEGMENT_ATTRIBUTE12,
                       SEGMENT_ATTRIBUTE13  =   @SEGMENT_ATTRIBUTE13,
                       SEGMENT_ATTRIBUTE14  =   @SEGMENT_ATTRIBUTE14,
                       SEGMENT_ATTRIBUTE15  =   @SEGMENT_ATTRIBUTE15,
                       SEGMENT_ATTRIBUTE16  =   @SEGMENT_ATTRIBUTE16,
                       SEGMENT_ATTRIBUTE17  =   @SEGMENT_ATTRIBUTE17,
                       SEGMENT_ATTRIBUTE18  =   @SEGMENT_ATTRIBUTE18,
                       SEGMENT_ATTRIBUTE19  =   @SEGMENT_ATTRIBUTE19,
                       SEGMENT_ATTRIBUTE20  =   @SEGMENT_ATTRIBUTE20,
                       SEGMENT_ATTRIBUTE21  =   @SEGMENT_ATTRIBUTE21,
                       SEGMENT_ATTRIBUTE22  =   @SEGMENT_ATTRIBUTE22,
                       SEGMENT_ATTRIBUTE23  =   @SEGMENT_ATTRIBUTE23,
                       SEGMENT_ATTRIBUTE24  =   @SEGMENT_ATTRIBUTE24,
                       SEGMENT_ATTRIBUTE25  =   @SEGMENT_ATTRIBUTE25,
                       SEGMENT_ATTRIBUTE26  =   @SEGMENT_ATTRIBUTE26,
                       SEGMENT_ATTRIBUTE27  =   @SEGMENT_ATTRIBUTE27,
                       SEGMENT_ATTRIBUTE28  =   @SEGMENT_ATTRIBUTE28,
                       SEGMENT_ATTRIBUTE29  =   @SEGMENT_ATTRIBUTE29,
                       SEGMENT_ATTRIBUTE30  =   @SEGMENT_ATTRIBUTE30,
                       SEGMENT_ATTRIBUTE31  =   @SEGMENT_ATTRIBUTE31,
                       SEGMENT_ATTRIBUTE32  =   @SEGMENT_ATTRIBUTE32,
                       SEGMENT_ATTRIBUTE33  =   @SEGMENT_ATTRIBUTE33,
                       SEGMENT_ATTRIBUTE34  =   @SEGMENT_ATTRIBUTE34,
                       SEGMENT_ATTRIBUTE35  =   @SEGMENT_ATTRIBUTE35,
                       SEGMENT_ATTRIBUTE36  =   @SEGMENT_ATTRIBUTE36,
                       SEGMENT_ATTRIBUTE37  =   @SEGMENT_ATTRIBUTE37,
                       SEGMENT_ATTRIBUTE38  =   @SEGMENT_ATTRIBUTE38,
                       SEGMENT_ATTRIBUTE39  =   @SEGMENT_ATTRIBUTE39,
                       SEGMENT_ATTRIBUTE40  =   @SEGMENT_ATTRIBUTE40,
                       SEGMENT_ATTRIBUTE41  =   @SEGMENT_ATTRIBUTE41,
                       SEGMENT_ATTRIBUTE42  =   @SEGMENT_ATTRIBUTE42,
                       REFERENCE1  =   @REFERENCE1,
                       REFERENCE2  =   @REFERENCE2,
                       REFERENCE3  =   @REFERENCE3,
                       REFERENCE4  =   @REFERENCE4,
                       REFERENCE5  =   @REFERENCE5,
                       JGZZ_RECON_FLAG  =   @JGZZ_RECON_FLAG,
                       JGZZ_RECON_CONTEXT  =   @JGZZ_RECON_CONTEXT,
                       PRESERVE_FLAG  =   @PRESERVE_FLAG,
                       REFRESH_FLAG  =   @REFRESH_FLAG,
                       IGI_BALANCED_BUDGET_FLAG  =   @IGI_BALANCED_BUDGET_FLAG,
                       COMPANY_COST_CENTER_ORG_ID  =   @COMPANY_COST_CENTER_ORG_ID,
                       REVALUATION_ID  =   @REVALUATION_ID,
                       LEDGER_SEGMENT  =   @LEDGER_SEGMENT,
                       LEDGER_TYPE_CODE  =   @LEDGER_TYPE_CODE,
                       ALTERNATE_CODE_COMBINATION_ID  =   @ALTERNATE_CODE_COMBINATION_ID
                   Where CODE_COMBINATION_ID=@CODE_COMBINATION_ID  
              End
          Else if @DML_TYPE = 'D'        
              Begin        
                   Delete from GL_CODE_COMBINATIONS
                     Where CODE_COMBINATION_ID=@CODE_COMBINATION_ID
              End
End
