Over the past week, some of our readers have informed us that they have encountered the sp2-0552 error in Oracle.
This SP2-0552 error is because the specified bind variable was not created. Run the VARIABLE command to check if the bind variables you used in your SQL statement exist. Before running an SQL statement with variance variables, you must use the VARIABLE command to declare each variable.
Also note that the typical use of hole variables spans the literal this string in the WHERE predicate, so you can replace the department name next to it (so that you can use the same query for all departments).
VARIABLE v_max_sal NUMBER;VARIABLE v_dname VARCHAR2 (14);begin: v_dname: = max (sal) 'SALE';Select EN: v_max_salAuthor: scott.emp e, scott.dept dwhere e.deptno = d.deptnoand D. = dname: v_dname;END;/print v_max_sal;
You can also remove the colon to start with a variable, and that gets tiresome too:
SQL> sets the server output toDeclare SQL> second v_max_sal NUMBER (20); 3. Start 4 prefer max (sal) IN v_max_sal all five from scott.emp e, scott.dept d eight, where e.e.deptno = d.deptno some and d.dname = 'SALES'; dbms_output It is important. put_line (v_max_sal); 9 END; ten /2850
Note that this option results in a similar query in your database in addition to the solution suggested by @Alex:
SELECT MAX (SAL) DE SCOTT.EMP E, SCOTT.DEPT D O E.DEPTNO = D.DEPTNO ET D.DNAME = 'SALES'
The extended option at the beginning that is linked to this answer results in reflection with BV in the WHERE clause:
SELECT MAX. (SALE) SCOTT.EMP E, SCOTT.DEPT D O E.DEPTNO = D.DEPTNO AND D.DNAME =: B1
Question: what to do?What am I doing to fix PL / SQL error SP2-0552?