oracle - scope of raise exception, handling your own exceptions in PLSQL code -


I have this process:

  The process is to create or change the cursor cursor oldemployees Select * Emp1 from WHERE data_saida = NULL; New_ndep emp1.num_dep% type; Bi_inexistente exception; Dep_inexistente exception; EmployeeNr emp1.num_empregado% type; Old employee employee LOOP employee for old_emp: = old_emp.num_empregado; If (old_emp.bi = NULL) then increase bi_inexistente; Else IF (old_emp.num_dep> 20) then again in the new_ndep in CONVERTI_APP where ndep_antigo = old_emp.num_dep; Elsef (old_emp.num_dep = NULL) then new_ndep: = 0; Lift dep_inexistente; end if; Insert EMP2 values ​​(old_map.b, old_map.nawm, old_map.moder, old_map_data_antry, old_map_data_saida, new_ndp); COMMIT; end if; End loop; Exceptions when bi_inexistente then INSERT in Eros Value (employee name, 'bi inextent'); COMMIT; When dep_nexistente then include in Eros values ​​(employee, 'Departamento Inexistente'); COMMIT; End;  

I want to include the EMP2 value (old_emp.bi, old_emp.nome, old_emp.morada, old_emp.data_entrada, old_emp.data_saida, new_ndep); Even after raising dep_inexistente, but after reading the reference to Oracle, I am a little confused; In fact, when it is empty, I do not want to include that, otherwise I want to get involved, even if the department number is zero (which comes to 0).

So, this code is getting right or how should I raise my exceptions or how to handle pre-defined exceptions for my case?

I do not think exceptions should be used as an incompatible GOTO statement. If you want to make your code, then you can use the procedures (and subprocessing) if the code code is used in one place, then use the return statement just then take exception if it makes sense.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -