exception sequence.nextval maxvalue? (oracle sql) -
i want catch specific exception thrown when sequence.nextval
reaches maxvalue in oracle?
i don't want use exception when others; want catch specific exception logger.
you can declare user defined exception , associate exception code -8004
(the code of exception raised when sequence exceeds maximum value) using pragma exception_init()
, catch specific exception. here example:
sql> declare 2 l_ex_max_val exception; 3 pragma exception_init(l_ex_max_val, -8004); 4 l_val number; 5 begin 6 l_val := gen_val.nextval; -- kind of assignment allowed 7 exception -- in 11g , further versions. in earlier versions 8 when l_ex_max_val -- use select statement 9 dbms_output.put_line('error! sequence gen_val exceeds max value'); 10 end; 11 / error! sequence gen_val exceeds max value pl/sql procedure completed sql>
Comments
Post a Comment