I have a huge file which contains multiple lines. It need to check whether character length is not more than 255 each line. If its not then it should remove the
character up to column
. I have described in the output below. If its more than that
the next line should start with call
but if the table name varies then it should not merge to the same line. The output should go to the 4 different file based upon the table name in the 3rd column below. 5th table in the list should again go the first file.
Input:
call mq_dbrebuildindex('SCS.services_HIST','column [end_dt]');
call mq_dbrebuildindex('SCS.services_HIST','column [status]');
call mq_dbrebuildindex('SCS.services_HIST','column [survey]');
call mq_dbrebuildindex('SCS.services_HIST','column [file_id]');
call mq_dbrebuildindex('SCS.services_HIST','column [opt_out]');
call mq_dbrebuildindex('SCS.services_HIST','column [start_dt]');
call mq_dbrebuildindex('SCS.services_HIST','column [dw_load_dt]');
call mq_dbrebuildindex('SCS.services_HIST','column [pip_brands]');
call mq_dbrebuildindex('SCS.services_HIST','column [finalize_dt]');
call mq_dbrebuildindex('SCS.services_HIST','column [scs_service]');
call mq_dbrebuildindex('SCS.services_HIST','column [pharmacy_ncpdp]');
call mq_dbrebuildindex('SCS.services_HIST','column [contract_term_sheet]');
call mq_dbrebuildindex('SCS.reporting_opportunities','column [file_id]');
call mq_dbrebuildindex('SCS.reporting_opportunities','column [fnlndbs]');
call mq_dbrebuildindex('SCS.reporting_opportunities','column [payer_id]');
call mq_dbrebuildindex('SCS.reporting_opportunities','column [pip_edit]');
Output:
File:1
call mq_dbrebuildindex('SCS.services_HIST','column [end_dt]) column [status] column [survey] column [file_id]) column [opt_out] column [start_dt] column [dw_load_dt] column [pip_brands] column [finalize_dt] column [scs_service] column [pharmacy_ncpdp]');
call mq_dbrebuildindex('SCS.services_HIST','column [contract_term_sheet]');
File:2
call mq_dbrebuildindex('SCS.reporting_opportunities','column [file_id] column [fnlndbs]column [payer_id]column [pip_edit]column [client_id]column [person_id]column [rx_number]column [copay_tier]column [dw_load_dt]column [patient_id]column [program_id]')
call mq_dbrebuildindex('SCS.reporting_opportunities','column [billing_ndc]column [days_supply]column [employer_id]column [fill_number]column [claim_number]column [client_id_cd]column [pharmacy_npi]column [processed_dt]column [date_of_birth]')
call mq_dbrebuildindex('SCS.reporting_opportunities','column [employer_name]column [latest_fax_id]column [prescriber_id]column [record_source]column [patient_gender]column [pharmacy_ncpdp]column [transaction_cd]column [date_of_service]');
call mq_dbrebuildindex('SCS.reporting_opportunities','column [date_rx_written]column [earliest_fax_id]column [patient_pay_amt]column [transaction_type]column [dispense_event_id]column [dispensing_status]column [patient_gender_cd]');
File:3
File:4