What is the best way to bypass the Oracle SQL reserved-word constraint for PL/SQL value declaration? I realize bind and substitution may be acceptable alternatives for an actual query, but what about Oracle PL/SQL? For example I would like to declare a numeric variable as “num”, structured below within the Oracle PL query:
SET SERVEROUTPUT ON declare num number; begin num := 10; DBMS_OUTPUT.put_line('The value of num ' || num); end;
NUM is not a reserved word.
The best way is not to use reserved words.
If you insist on using them, you can put them between quotation marks. This does not work:
SET SERVEROUTPUT ON declare begin number; begin begin := 10; DBMS_OUTPUT.put_line('The value of begin ' || begin); end; /
SET SERVEROUTPUT ON declare "begin" number; begin "begin" := 10; DBMS_OUTPUT.put_line('The value of begin ' || "begin"); end; /
Quotation marks also make the variable name case-sensitive.
"BEGIN" are different variables.