Oracle 给我错误“ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at line 15 06502. 00000 - “PL/SQL: numeric or value error%s”
DECLARE
idnumber NUMBER(10);
initials VARCHAR2(100);
userid VARCHAR2(100);
old_initials VARCHAR2(100);
CURSOR cursor1 IS
SELECT s_first, s_last FROM tst_student ORDER BY s_first;
student cursor1%ROWTYPE;
BEGIN
FOR student IN cursor1 LOOP
idnumber :=1;
old_initials := SUBSTR(student.s_first,1,1) || SUBSTR(student.s_last,1,1);
initials := SUBSTR(student.s_first,1,1) || SUBSTR(student.s_last,1,1);
IF initials = old_initials THEN
userid := old_initials || '00' || idnumber + 1;
ELSE idnumber := 1;
END IF;
DBMS_OUTPUT.PUT_LINE(userid);
END LOOP;
END;
它抱怨的那一行是 userid := old_initials || '00' || 身份证号码 + 1;
谢谢