check for existing file in directory devest/dev_XXXXX if yes then start from that point if not then Get app id from dev_apps table and dump into file apps.txt for appid (read each record individually and do following) var1=select entire record of appid into variable get est_dev_id for that app_id from dev_est table and dump into file dev_est.txt for est_dev_id (read each record individually and do following) var2=select entire record of dev_est into variable get est_dev_req_id for that est_dev_id from dev_est_reqs table and dump file dev_est_req.txt for est_dev_req_id (do following) var3=select entire record of dev_est_req get est_dev_req_status_id for that est_dev_reqs_id from dev_est_reqs_status table and dump file dev_est_req_status.txt for est_dev_req_status_id (do following var4=select entire record of dev_est_req_status echo $Var1 + $var2 + $var3 + $var4 apply conditions / validations i.e var1.col1 or var1.col4 is null, var2.col2, var2.col5, etc if, else, elseif, cases, etc prompt user for action load devest/dev_XXXX for initial delete dev_est_req_id, update dev_est_req.txt for continuation default input condition else condition here insert into logs check for insert success insert into some table check for insert success