Skip to Main Content

Switch off particular PL/SQL warnings in code

When compiling PL/SQL sources, I always switch all warnings on in order to get as many pointers to potential issues in my code as possible. I then check these warnings and may or may not change the code. If I leave the code as is for some reason, I want to be able to tell the DBMS that I have seen the warning, checked the code, am fine with it and don't want to see the warning ever again.
For instance, if in my PL/SQL package I have a query like this:

select *
bulk collect into v_items
from item
where lib_item.is_item_active(id) = 1;

I'll get
PLW-07204: conversion away from column type may result in sub-optimal query plan
Now I want to tell the compiler that in this particular line it shall not report this any longer. Something like

select *
bulk collect into v_items
from item
PRAGMA PLW-07204:OFF -- the DBMS cannot use an index on the ID here, and that is okay
where lib_item.is_item_active(id) = 1;
PRAGMA PLW-07204:DEFAULT

(I've chosen PRAGMA here, because this is what we use to give information to the compiler, but that's just a suggestion.)

Comments
Post Details
Added on Jul 5 2022
0 comments
2 views