I want to compile this PL/SQL program in the SQL window that belongs to the Database Home page:
DEFINE p_annual_sal=60000
DECLARE
v_sal NUMBER(9,2):=&p_annual_sal;
BEGIN
v_sal:=v_sal/12;
DBMS_OUTPUT.PUT_LINE('The monthly salary is '|| TO_CHAR(v_sal));
END;
When I hit run I got the following message:
ORA-00900: invalid SQL statement
Even though it works under SQL*Plus of the command line, what it could be the issue?
It works in SQL*Plus because
DEFINEis a SQL*Plus command.When you refer to the “database home page” I believe you’re referring to Oracle Apex’s SQL Commands window, which can run SQL and PL/SQL code, but not SQL*Plus commands.
You can do this instead – Apex will prompt you for the input bind variables, if any: