RACK_CODE_TO->ID; //Get the current rack data $sql = "SELECT rack_code, rack_type, ref_no, brand, quantity, customer, irrd, serial_no, size_code, inspection_id, line_id FROM ytycustom.gth_rack_master WHERE rack_code = :rack_code"; $sqlarr = oci_parse($dbcon , $sql); oci_bind_by_name($sqlarr, ':rack_code', $data->RACK_CODE_FROM); $r = oci_execute($sqlarr); if (!$r) { $e = oci_error($sqlarr); print json_encode($e['message']); } oci_fetch_all($sqlarr, $rows_current, null, null, OCI_FETCHSTATEMENT_BY_ROW); if ($rows_current[0]["RACK_TYPE"] == "NS") { //Update Detail $sql_det = " UPDATE ytycustom.xx_yty_incoming_outgoing_inspection_detail_tbl SET racking_no = :rack_code WHERE id = :line_id AND inspection_id = :inspection_id"; $sqlarr_det = oci_parse($dbcon , $sql_det); oci_bind_by_name($sqlarr_det, ':rack_code', $data->RACK_CODE_TO->ID); oci_bind_by_name($sqlarr_det, ':line_id', $rows_current[0]["LINE_ID"]); oci_bind_by_name($sqlarr_det, ':inspection_id', $rows_current[0]["INSPECTION_ID"]); $r = oci_execute($sqlarr_det, OCI_NO_AUTO_COMMIT); if (!$r) { $e = oci_error($sqlarr_det); $errorMsg = json_encode($e['message']); goto finalStep; } } else if ($rows_current[0]["RACK_TYPE"] == "S") { //Update Detail $sql_det = " UPDATE ytycustom.xx_yty_incoming_outgoing_inspection_detail_stl SET racking_no = :rack_code WHERE id = :line_id AND inspection_id = :inspection_id"; $sqlarr_det = oci_parse($dbcon , $sql_det); oci_bind_by_name($sqlarr_det, ':rack_code', $data->RACK_CODE_TO->ID); oci_bind_by_name($sqlarr_det, ':line_id', $rows_current[0]["LINE_ID"]); oci_bind_by_name($sqlarr_det, ':inspection_id', $rows_current[0]["INSPECTION_ID"]); $r = oci_execute($sqlarr_det, OCI_NO_AUTO_COMMIT); if (!$r) { $e = oci_error($sqlarr_det); $errorMsg = json_encode($e['message']); goto finalStep; } } //Empty The Rack $sql_det = " UPDATE ytycustom.gth_rack_master SET occupied = NULL, ref_no = NULL, customer = NULL, brand = NULL, size_code = NULL, quantity = NULL, irrd = NULL, serial_no = NULL, inspection_id = NULL, line_id = NULL WHERE rack_code = :rack_code"; $sqlarr_det = oci_parse($dbcon , $sql_det); oci_bind_by_name($sqlarr_det, ':rack_code', $data->RACK_CODE_FROM); $r = oci_execute($sqlarr_det, OCI_NO_AUTO_COMMIT); if (!$r) { $e = oci_error($sqlarr_det); $errorMsg = json_encode($e['message']); goto finalStep; } //Racking $sql_rak = "UPDATE YTYCUSTOM.GTH_RACK_MASTER SET OCCUPIED = 'Y', REF_NO = :REF_NO, CUSTOMER = :CUSTOMER, BRAND = :BRAND, SIZE_CODE = :SIZE_CODE, QUANTITY = :QUANTITY, INSPECTION_ID = :INSPECTION_ID, LINE_ID = :LINE_ID WHERE RACK_CODE = :RACK_CODE"; $sqlarr_rak = oci_parse($dbcon , $sql_rak); oci_bind_by_name($sqlarr_rak, ':REF_NO', $rows_current[0]["REF_NO"]); oci_bind_by_name($sqlarr_rak, ':CUSTOMER', $rows_current[0]["CUSTOMER"]); oci_bind_by_name($sqlarr_rak, ':BRAND', $rows_current[0]["BRAND"]); oci_bind_by_name($sqlarr_rak, ':SIZE_CODE', $rows_current[0]["SIZE_CODE"]); oci_bind_by_name($sqlarr_rak, ':QUANTITY', $rows_current[0]["QUANTITY"]); oci_bind_by_name($sqlarr_rak, ':INSPECTION_ID', $rows_current[0]["INSPECTION_ID"]); oci_bind_by_name($sqlarr_rak, ':LINE_ID', $rows_current[0]["LINE_ID"]); oci_bind_by_name($sqlarr_rak, ':RACK_CODE', $data->RACK_CODE_TO->ID); $r = oci_execute($sqlarr_rak, OCI_NO_AUTO_COMMIT); if (!$r) { $e = oci_error($sqlarr_det); $errorMsg = json_encode($e['message']); goto finalStep; } finalStep: $result = []; if ($errorMsg == "") { oci_commit($dbcon); $result[] = [ "message" => "Success", "id" => $newid ]; } else { oci_rollback($dbcon); $result[] = [ "message" => $errorMsg, "id" => "" ]; } print json_encode($result); ?>