Oracle errors handling

前端 未结 2 349
北荒
北荒 2020-12-21 05:03

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         


        
2条回答
  •  猫巷女王i
    2020-12-21 05:33

    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 ;
    

提交回复
热议问题