我该如何修复 "PL/SQL: numeric or value error%s"?

How I can fix "PL/SQL: numeric or value error%s"?

我正在尝试编写一个程序。当我们用 id no 查询这个过程时,
表将被连接,结果如下;
(PROCEDURE_NAME: "student_information")
id_no,姓名,姓氏,school_number,department_information,城市,课程


这是我的表格和程序代码;

CREATE TABLE student_info (
    school_number NUMBER,
    id_no NUMBER NOT NULL UNIQUE,
    name VARCHAR2(50) NOT NULL,
    surname VARCHAR2(50) NOT NULL,
    city VARCHAR2(50) NOT NULL,
    birth_date DATE NOT NULL,
    CONSTRAINT student_info_pk PRIMARY KEY (okul_numarasi)
);
CREATE TABLE school_info (
    school_number NUMBER,
    entry_date DATE NOT NULL,
    faculty_info VARCHAR2(50) NOT NULL,
    department_information VARCHAR2(50) NOT NULL,
    CONSTRAINT school_info_pk PRIMARY KEY (school_number),
    CONSTRAINT student_school_fk FOREIGN KEY (school_number)      
    REFERENCES student_info(school_number)
);
CREATE TABLE lessons(
     school_number NUMBER,
     lesson_name VARCHAR2(100) NOT NULL,
     lesson_number NUMBER NOT NULL,
     midterm_1 NUMBER,
     midterm_2 NUMBER,
     final_note NUMBER,
     integration_note NUMBER, 
    CONSTRAINT lessons_pk PRIMARY KEY (school_number),
    CONSTRAINT lessons_student_fk FOREIGN KEY (school_number)     
    REFERENCES ogrenci_bilgileri (okul_numarasi)
);

CREATE OR REPLACE PROCEDURE 
      student_information(
                     p_no                     IN  student_info.id_no%type,
                     p_name                   OUT student_info.name%type,
                     p_surname                OUT student_info.surname%type,
                     p_school_number          OUT student_info.school_number%type,
                     p_department_information OUT school_info.department_information%type,
                     p_city                   OUT student_info.city%type,
                     p_lesson                 OUT lessons.lesson_name%type
                   ) AS
BEGIN
  SELECT o.name,
         o.surname,
         o.school_number,
         ok.department_information,
         o.city,
         d.lesson_name
    INTO p_name,
         p_surname,
         p_school_number,
         p_city,
         p_department_information,
         p_lesson
    FROM student_info o
    JOIN school_info ok
      ON o.school_info = ok.school_number
    JOIN lessons d
      ON d.school_number = ok.school_number;
   WHERE o.id_no = p_no;
END student_information;

这是我向 运行 声明的程序。

DECLARE 
    v_id student_info.id_no%type:= 12345;      
    v_name student_info.name%type;      
    v_surname student_info.surname%type;      
    v_school_num student_info.school_number%type;      
    v_department school_info.department_information%type;      
    v_city student_info.city%type;      
    v_lesson lessons.lesson_name%type;
BEGIN
    student_information(v_id,v_name,v_surname,v_school_num,v_department,v_city, v_lesson );
    DBMS_OUTPUT.put_line ('Student Information');
    DBMS_OUTPUT.put_line ('ID: ' || v_id);
    DBMS_OUTPUT.put_line ('Name: ' || v_name || ' ' || v_surname);
    DBMS_OUTPUT.put_line ('School Number: ' || v_school_num);
    DBMS_OUTPUT.put_line ('Department Information: ' || v_department);
    DBMS_OUTPUT.put_line ('City: ' || v_city);
    DBMS_OUTPUT.put_line ('Lesson Name:' || v_lesson);
END;

错误是:

ORA-06502: PL / SQL: numerical or value error: character-to-number error
ORA-06512: location "SYSTEM.student_information", line 12
ORA-06512: location line 10
06502. 00000 -  "PL/SQL: numeric or value error%s"
*Cause:    An arithmetic, numeric, string, conversion, or constraint error
           occurred. For example, this error occurs if an attempt is made to
           assign the value NULL to a variable declared NOT NULL, or if an
           attempt is made to assign an integer larger than 99 to a variable
           declared NUMBER(2).
*Action:   Change the data, how it is manipulated, or how it is declared so
           that values do not violate constraints.

您的列简单不匹配

  SELECT o.name,
         o.surname,
         o.school_number,
         ok.department_information,   <===
         o.city,                      <===
         d.lesson_name
    INTO p_name,
         p_surname,
         p_school_number,
         p_city,                      <===
         p_department_information,    <===
         p_lesson

但在您拍打自己的脑袋并认为您浪费了时间之前,您所做的更改(使用 %TYPE 等)已经使您的代码更加健壮和可维护。