エラー処理の極意

仕事をしていると細かいエラーに悩まされることが多々あります。
そんなときどういった対処をするか?
これを用意しておくことで、
エラーの原因解決に行き着く時間短縮することができます。

エラー処理はこちら↓

select
apply_end_time - apply_start_time - rest_time - over_rest_time
from trn_work_time
where id = 40;
←エラー発生 どこでエラーが出てるかわかりません。

そんな時は徐々に問題解決をしていく。

①select rest_time from trn_work_time where id=40;	
→問題なし

②select over_rest_time from trn_work_time 
where id=40;
→問題なし

③select apply_end_time - apply_start_time  
from trn_work_time where id=40;
→問題なし

④select apply_end_time - apply_start_time - rest_time
 from trn_work_time where id=40;
→エラー発生
原因はrest_timeがnullのときがあったから...

⑤select apply_end_time - apply_start_time - rest_time
 - over_rest_time from trn_work_time where id=40;
問題解決