Error ORA-06502: PL / SQL

2

I have the following procedure:

CREATE or REPLACE PROCEDURE QUERY_EMP
(id IN emp.empno%TYPE, salario OUT emp.sal%TYPE, puesto OUT emp.job%TYPE) 
IS
BEGIN
  SELECT job, sal
  INTO salario, puesto
  FROM emp
  WHERE empno = id;
END QUERY_EMP;

And by calling it in this way to prove it with this:

Declare
id emp.empno%TYPE := 7844;
salario emp.sal%TYPE;
puesto emp.job%TYPE;
BEGIN 
    QUERY_EMP(id, salario, puesto);
    DBMS_OUTPUT.PUT_LINE(salario);
    DBMS_OUTPUT.PUT_LINE(puesto);
END;

I get this error:

  

ORA-06502: PL / SQL: error: character to number conversion error   numerical or value.

I do not understand why it jumps if the data type is the same and exists in the database.

    
asked by Don Protón 08.05.2018 в 20:52
source

1 answer

3

I found the error, when doing the select:

....
SELECT sal, job
INTO puesto, salario
....

I assign the values to the variables that are not, and having a different type of data gives an error. The correct thing is:

....
SELECT sal, job
INTO salario, puesto
....
    
answered by 08.05.2018 в 20:57