I have such code:
DECLARE e_not_exist EXCEPTION; PRAGMA EXCEPTION_INIT(e_not_exist, -942); car_name VARCHAR2(20); BEGIN select name_of_factory into c
You can't do that with static SQL. The error is coming when the code is being compiled, not executed. Try this instead:
execute immediate 'select name_of_factory from car where car_id = 1' into car_name ;